NOTES FROM SF:
FOR STEAMBOAT, COMPARE THE DETRENDED CLIAMTE NORMAL CURVES AGAINST EACH OTHER
Derry & fassnacht 2010 Compare climatology of SNOTEL stations= they don’t have the same climatol9ogy based on the snow data
Figure 5b - https://agupubs.onlinelibrary.wiley.com/doi/10.1029/2009WR007835
This work is very preliminary as I get back into the coding swing of things. Data wrangling and figure generation will be done via R, but the rest of the project will be done using good ol’ microsoft products. This is just an entry point into data crunching and should by no means be considered a final product.
Also, I’m not great at this but whatever. I could automate this, but I’ll figure that out shortly!
Need to update figures & analyze sites for seasonal trends
SNOTEL data was provided by the NRCS. Data was cleaned by removing outliers that are likely implausible; any year with more than 15 observations missing was removed. Temperatures were adjusted using the Morrisey method for stations identified by Ma et al (2019) due to SNOTEL temperature sensor changes, with the adjustment applied to pre-sensor change data. Daily mean observations were detrended to determine whether values were increasing or decreasing from the entire time series trend. Daily mean temperatures were first averaged by water year, with all water year means then averaged by day of water year. The mean temperature by day for the period of record was averaged. To find the standard deviation, the daily mean temperatures by water year was subtracted from the averaged mean temperature by day for the period of record. All water year means averaged by day of water year were subtracted from the temperature mean. The resulting values were then added together to find the “residual” of the daily mean temperatures by water year. The standard deviation was then computed from those residuals, with trends analyzed by Mann‐Kendall significance test and Theil‐Sen’s rate of change. Significant trends are identified with p-values of less than 0.10.
Morrisey Method
The Morrisey Method is taken from Ma, Fassnacht and Kampf..
In R script: T(adjusted) = 5.3x10(-7)xT(old)4+3.72x10(-5)xT(old)3-2.16x10(-3)xT(old)2-7.32x10^(-2)xT(old)+1.37
In the Ma et al. spreadsheet, H1 is Morrisey, H2 is Oiler
Analyzing by summer and winter seasons for each station’s timeseries, using the shifted mean of the time series, then sigmoidal detrending. Standard deviation is taken with the relevant days of the water year.
Analyzing for spring and fall….
Yampa Area SNOTEL sites:
Burro Mountain 378 NSCE- Original, Bias- Morrisey 7/11/2002 (NSCE- 0.87 vs 0.84, Bias- -0.03 vs. 0.11)
Columbine 408 Morrisey 7/22/2005
Columbine Pass 409 Morrisey 6/23/2005
Crosho 426 Morrisey 7/21/2005
Dry Lake 457 Oyler -> Morrisey 7/30/2003
Elk River 467 Oyler -> Morrisey 8/7/2006
Lynx Pass 607 Morrisey 5/22/2006
Rabbit Ears 709 Morrisey 8/7/2006 (Does not go.)
Ripple Creek 717 Oyler -> Morrisey 8/7/2006
Tower 825 Original 8/18/2004
Trapper Lake 827 Original 12/13/2004
SNOTEL_yampa_area <- snotel_download(site_id = c(378, 408, 409, 426, 457, 467, 607, 709, 717, 825, 827), path = tempdir('../data'), internal = TRUE)
write.csv(SNOTEL_yampa_area,"C:/Users/13074/Documents/ESS580/thesis_project/Yampa/data_raw/snotel_yampa.csv", row.names = FALSE) #write in the raw data
SNOTEL_yampa_area <- read.csv("C:/Users/13074/Documents/ESS580/thesis_project/Yampa/data_raw/snotel_yampa.csv", header = TRUE)
NSCE- Original, Bias- Morrisey 7/11/2002 so, ORIGINAL. Morrisey is marked as having the smallest bias, but the sheet says original is smaller.
snotel_378 <- SNOTEL_yampa_area %>%
filter(site_id == "378")
#str(snotel_378) # check the date, usually a character.
snotel_378$Date <- as.Date(snotel_378$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_378_clean <- snotel_378 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_378_clean <- snotel_378_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_378_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_378_clean <- snotel_378_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40)# %>%
#filter(temperature_mean < 25)
ggplot(snotel_378_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_378_cull_count <- snotel_378_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_378_cull_count
# filtering for too few observations in a year
snotel_378_cull_count_days <- snotel_378_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_378_cull_count_days
## # A tibble: 10 x 2
## # Groups: waterYear [10]
## waterYear n
## <dbl> <int>
## 1 1985 1
## 2 1988 298
## 3 1989 341
## 4 1993 281
## 5 1994 261
## 6 1995 344
## 7 1996 320
## 8 2002 312
## 9 2016 310
## 10 2022 338
snotel_378_clean_culled <- snotel_378_clean %>%
filter(waterYear != "1985" & waterYear != "1986" & waterYear != "1988" & waterYear != "1989" & waterYear != "1993" & waterYear != "1994" & waterYear != "1995" & waterYear != "1996" & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_378_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Culling WY 1986 as well.
ggplot(snotel_378_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_378_xts <- xts(snotel_378_clean_culled$temperature_mean, order.by = snotel_378_clean_culled$Date)
dygraph(temp_378_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_378_clean_culled <- snotel_378_clean_culled %>%
# filter(temperature_mean < 19.3)
temp_378_xts <- xts(snotel_378_clean_culled$temperature_mean, order.by = snotel_378_clean_culled$Date)
dygraph(temp_378_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
NSCE- Original, Bias- Morrisey 7/11/2002
snotel_378_adjusted <- snotel_378_clean_culled %>%
mutate(temp_ad = if_else(Date < "2002-07-11", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_378 <- snotel_378_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_378 <- yearly_wy_aver_378 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(temperature_mean))
#average mean temperature by day for the period of record:
daily_wy_aver_378 <- daily_wy_aver_378 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_378$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_378 <-daily_wy_aver_378 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_378$date_temp <- signif(daily_wy_aver2_378$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_378, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_378 <- daily_wy_aver_378 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_378 <- standard_dev_378 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_378 <- standard_dev_all_378 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_378 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.844333 |
| 1990 | 3.840459 |
| 1991 | 4.152285 |
| 1992 | 3.762154 |
| 1997 | 3.990912 |
| 1998 | 3.720044 |
| 1999 | 3.917633 |
| 2000 | 3.912993 |
| 2001 | 3.855899 |
| 2003 | 3.665924 |
| 2004 | 4.000526 |
| 2005 | 3.480996 |
| 2006 | 3.976868 |
| 2007 | 3.874997 |
| 2008 | 3.754838 |
| 2009 | 3.615420 |
| 2010 | 3.592359 |
| 2011 | 3.866506 |
| 2012 | 3.431475 |
| 2013 | 4.071795 |
| 2014 | 3.589962 |
| 2015 | 3.810310 |
| 2017 | 4.047282 |
| 2018 | 3.371707 |
| 2019 | 3.627857 |
| 2020 | 4.080397 |
| 2021 | 3.694656 |
ggplot(standard_dev_all_378, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 378 average temperatures for water years 2005-2021
sd_mk_378 <- mk.test(standard_dev_all_378$sd_2)
print(sd_mk_378)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_378$sd_2
## z = -1.2925, n = 27, p-value = 0.1962
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -63.0000000 2301.0000000 -0.1794872
sd_sens_378 <- sens.slope(standard_dev_all_378$sd_2)
print(sd_sens_378)
##
## Sen's slope
##
## data: standard_dev_all_378$sd_2
## z = -1.2925, n = 27, p-value = 0.1962
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.019352100 0.004261212
## sample estimates:
## Sen's slope
## -0.00808587
#using the clean culled df:
#average water year temperature
yearly_wy_aver_378_ad <- snotel_378_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_378_ad <- yearly_wy_aver_378_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_378_ad <- daily_wy_aver_378_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_378_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_378_ad <-daily_wy_aver_378_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_378_ad$date_temp_ad <- signif(daily_wy_aver2_378_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_378_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_378_ad <- daily_wy_aver_378_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_378_ad <- standard_dev_378_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_378_ad <- standard_dev_all_378_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_378_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.635402 |
| 1990 | 3.571781 |
| 1991 | 3.924198 |
| 1992 | 3.584506 |
| 1997 | 3.765809 |
| 1998 | 3.444660 |
| 1999 | 3.756325 |
| 2000 | 3.657796 |
| 2001 | 3.547148 |
| 2003 | 3.673553 |
| 2004 | 3.964851 |
| 2005 | 3.451173 |
| 2006 | 3.977442 |
| 2007 | 3.892954 |
| 2008 | 3.772474 |
| 2009 | 3.580080 |
| 2010 | 3.606648 |
| 2011 | 3.854514 |
| 2012 | 3.440420 |
| 2013 | 4.091489 |
| 2014 | 3.578326 |
| 2015 | 3.765488 |
| 2017 | 4.016757 |
| 2018 | 3.358551 |
| 2019 | 3.638647 |
| 2020 | 4.095520 |
| 2021 | 3.711136 |
ggplot(standard_dev_all_378_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 378 average temperatures for water years 1986-2021
sd_mk_378_ad <- mk.test(standard_dev_all_378_ad$sd_2)
print(sd_mk_378_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_378_ad$sd_2
## z = 0.79218, n = 27, p-value = 0.4283
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 39.0000000 2301.0000000 0.1111111
sd_sens_378_ad <- sens.slope(standard_dev_all_378_ad$sd_2)
print(sd_sens_378_ad)
##
## Sen's slope
##
## data: standard_dev_all_378_ad$sd_2
## z = 0.79218, n = 27, p-value = 0.4283
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.008353158 0.016292391
## sample estimates:
## Sen's slope
## 0.004238996
summer_standard_dev_all_378 <- standard_dev_378 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_378 <- summer_standard_dev_all_378 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_378 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.519944 |
| 1990 | 2.991647 |
| 1991 | 2.301635 |
| 1992 | 2.927244 |
| 1997 | 2.299028 |
| 1998 | 3.216968 |
| 1999 | 2.179241 |
| 2000 | 2.566396 |
| 2001 | 2.907393 |
| 2003 | 2.553179 |
| 2004 | 2.698694 |
| 2005 | 2.848247 |
| 2006 | 2.501620 |
| 2007 | 2.191416 |
| 2008 | 2.404034 |
| 2009 | 2.037832 |
| 2010 | 2.234948 |
| 2011 | 2.097951 |
| 2012 | 2.150713 |
| 2013 | 2.143274 |
| 2014 | 2.308825 |
| 2015 | 2.440864 |
| 2017 | 2.056110 |
| 2018 | 2.073730 |
| 2019 | 2.585254 |
| 2020 | 2.839585 |
| 2021 | 2.914442 |
ggplot(summer_standard_dev_all_378, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 378 average summer temperatures for water years 2005-2021
summer_sd_mk_378 <- mk.test(summer_standard_dev_all_378$sd_2)
print(summer_sd_mk_378)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_378$sd_2
## z = -1.7094, n = 27, p-value = 0.08737
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -83.0000000 2301.0000000 -0.2364672
summer_sd_sens_378 <- sens.slope(summer_standard_dev_all_378$sd_2)
print(summer_sd_sens_378)
##
## Sen's slope
##
## data: summer_standard_dev_all_378$sd_2
## z = -1.7094, n = 27, p-value = 0.08737
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.034019036 0.002611249
## sample estimates:
## Sen's slope
## -0.0129552
Winter
winter_standard_dev_all_378 <- standard_dev_378 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_378 <- winter_standard_dev_all_378 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_378 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.646858 |
| 1990 | 4.370827 |
| 1991 | 4.893370 |
| 1992 | 3.795916 |
| 1997 | 4.633640 |
| 1998 | 4.083586 |
| 1999 | 4.571204 |
| 2000 | 4.339714 |
| 2001 | 4.224920 |
| 2003 | 4.301637 |
| 2004 | 4.571834 |
| 2005 | 4.035326 |
| 2006 | 4.785264 |
| 2007 | 4.776866 |
| 2008 | 4.520852 |
| 2009 | 4.333085 |
| 2010 | 3.993484 |
| 2011 | 4.884186 |
| 2012 | 4.032196 |
| 2013 | 5.013664 |
| 2014 | 3.967656 |
| 2015 | 4.595698 |
| 2017 | 4.647297 |
| 2018 | 3.969930 |
| 2019 | 4.148917 |
| 2020 | 4.007006 |
| 2021 | 4.017442 |
ggplot(winter_standard_dev_all_378, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 378 average winter temperatures for water years 2005-2021
winter_sd_mk_378 <- mk.test(winter_standard_dev_all_378$sd_2)
print(winter_sd_mk_378)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_378$sd_2
## z = -1.2508, n = 27, p-value = 0.211
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -61.0000000 2301.0000000 -0.1737892
winter_sd_sens_378 <- sens.slope(winter_standard_dev_all_378$sd_2)
print(winter_sd_sens_378)
##
## Sen's slope
##
## data: winter_standard_dev_all_378$sd_2
## z = -1.2508, n = 27, p-value = 0.211
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.028694833 0.009594993
## sample estimates:
## Sen's slope
## -0.009648291
Summer
summer_standard_dev_all_378_ad <- standard_dev_378_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_378_ad <- summer_standard_dev_all_378_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_378_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.281137 |
| 1990 | 2.706950 |
| 1991 | 2.081504 |
| 1992 | 2.638399 |
| 1997 | 2.077041 |
| 1998 | 2.852230 |
| 1999 | 1.949459 |
| 2000 | 2.312759 |
| 2001 | 2.628411 |
| 2003 | 2.571301 |
| 2004 | 2.681783 |
| 2005 | 2.871469 |
| 2006 | 2.488610 |
| 2007 | 2.201130 |
| 2008 | 2.421151 |
| 2009 | 2.047690 |
| 2010 | 2.234717 |
| 2011 | 2.097755 |
| 2012 | 2.138574 |
| 2013 | 2.126970 |
| 2014 | 2.305642 |
| 2015 | 2.428691 |
| 2017 | 2.041059 |
| 2018 | 2.059623 |
| 2019 | 2.594543 |
| 2020 | 2.825679 |
| 2021 | 2.881607 |
ggplot(summer_standard_dev_all_378_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 378 average summer temperatures for water years 1986-2021
summer_sd_mk_378_ad <- mk.test(summer_standard_dev_all_378_ad$sd_2)
print(summer_sd_mk_378_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_378_ad$sd_2
## z = -0.25016, n = 27, p-value = 0.8025
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -13.00000000 2301.00000000 -0.03703704
summer_sd_sens_378_ad <- sens.slope(summer_standard_dev_all_378_ad$sd_2)
print(summer_sd_sens_378_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_378_ad$sd_2
## z = -0.25016, n = 27, p-value = 0.8025
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02112144 0.01493032
## sample estimates:
## Sen's slope
## -0.00199902
Winter
winter_standard_dev_all_378_ad <- standard_dev_378_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_378_ad <- winter_standard_dev_all_378_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_378_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.486747 |
| 1990 | 4.205583 |
| 1991 | 4.783651 |
| 1992 | 3.673412 |
| 1997 | 4.452262 |
| 1998 | 3.932303 |
| 1999 | 4.376905 |
| 2000 | 4.129924 |
| 2001 | 4.097792 |
| 2003 | 4.290050 |
| 2004 | 4.572725 |
| 2005 | 4.023538 |
| 2006 | 4.782438 |
| 2007 | 4.783581 |
| 2008 | 4.527273 |
| 2009 | 4.330641 |
| 2010 | 3.996081 |
| 2011 | 4.876192 |
| 2012 | 4.033049 |
| 2013 | 5.012588 |
| 2014 | 3.965097 |
| 2015 | 4.592748 |
| 2017 | 4.659374 |
| 2018 | 3.968231 |
| 2019 | 4.140915 |
| 2020 | 4.005496 |
| 2021 | 4.012923 |
ggplot(winter_standard_dev_all_378_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 378 average winter temperatures for water years 1986-2021
winter_sd_mk_378_ad <- mk.test(winter_standard_dev_all_378_ad$sd_2)
print(winter_sd_mk_378_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_378_ad$sd_2
## z = -0.29186, n = 27, p-value = 0.7704
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -15.00000000 2301.00000000 -0.04273504
winter_sd_sens_378_ad <- sens.slope(winter_standard_dev_all_378_ad$sd_2)
print(winter_sd_sens_378_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_378_ad$sd_2
## z = -0.29186, n = 27, p-value = 0.7704
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02107667 0.01715794
## sample estimates:
## Sen's slope
## -0.003978539
spring_standard_dev_all_378 <- standard_dev_378 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_378 <- spring_standard_dev_all_378 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_378 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.692000 |
| 1990 | 3.410893 |
| 1991 | 4.412912 |
| 1992 | 3.202418 |
| 1997 | 4.253521 |
| 1998 | 3.237115 |
| 1999 | 4.006045 |
| 2000 | 4.504179 |
| 2001 | 3.709817 |
| 2003 | 3.947462 |
| 2004 | 3.492848 |
| 2005 | 3.400284 |
| 2006 | 3.208628 |
| 2007 | 3.738166 |
| 2008 | 3.490849 |
| 2009 | 3.341240 |
| 2010 | 3.938693 |
| 2011 | 3.492053 |
| 2012 | 3.527092 |
| 2013 | 4.172600 |
| 2014 | 4.129458 |
| 2015 | 3.192933 |
| 2017 | 4.283350 |
| 2018 | 3.176609 |
| 2019 | 3.637517 |
| 2020 | 3.741933 |
| 2021 | 3.465805 |
ggplot(spring_standard_dev_all_378, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 378 average spring temperatures for water years 2005-2021
spring_sd_mk_378 <- mk.test(spring_standard_dev_all_378$sd_2)
print(spring_sd_mk_378)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_378$sd_2
## z = -0.50033, n = 27, p-value = 0.6168
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -25.00000000 2301.00000000 -0.07122507
spring_sd_sens_378 <- sens.slope(spring_standard_dev_all_378$sd_2)
print(spring_sd_sens_378)
##
## Sen's slope
##
## data: spring_standard_dev_all_378$sd_2
## z = -0.50033, n = 27, p-value = 0.6168
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02833277 0.01824868
## sample estimates:
## Sen's slope
## -0.002916373
Fall
fall_standard_dev_all_378 <- standard_dev_378 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_378 <- fall_standard_dev_all_378 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_378 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.375846 |
| 1990 | 3.739173 |
| 1991 | 3.796365 |
| 1992 | 4.431350 |
| 1997 | 4.026441 |
| 1998 | 3.731377 |
| 1999 | 3.512352 |
| 2000 | 3.758627 |
| 2001 | 3.237668 |
| 2003 | 2.778814 |
| 2004 | 4.158417 |
| 2005 | 2.524635 |
| 2006 | 3.922491 |
| 2007 | 3.365913 |
| 2008 | 3.451126 |
| 2009 | 3.299940 |
| 2010 | 3.875278 |
| 2011 | 2.997593 |
| 2012 | 3.008296 |
| 2013 | 3.349090 |
| 2014 | 3.597650 |
| 2015 | 3.111683 |
| 2017 | 4.013998 |
| 2018 | 3.456008 |
| 2019 | 3.550635 |
| 2020 | 5.506487 |
| 2021 | 4.064501 |
ggplot(fall_standard_dev_all_378, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 378 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_378 <- mk.test(fall_standard_dev_all_378$sd_2)
print(fall_sd_mk_378)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_378$sd_2
## z = -0.083388, n = 27, p-value = 0.9335
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -5.00000000 2301.00000000 -0.01424501
fall_sd_sens_378 <- sens.slope(fall_standard_dev_all_378$sd_2)
print(fall_sd_sens_378)
##
## Sen's slope
##
## data: fall_standard_dev_all_378$sd_2
## z = -0.083388, n = 27, p-value = 0.9335
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03098797 0.02672952
## sample estimates:
## Sen's slope
## -0.001408189
Spring
spring_standard_dev_all_378_ad <- standard_dev_378_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_378_ad <- spring_standard_dev_all_378_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_378_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.415274 |
| 1990 | 3.163959 |
| 1991 | 4.066110 |
| 1992 | 2.979428 |
| 1997 | 3.936885 |
| 1998 | 2.925370 |
| 1999 | 3.692620 |
| 2000 | 4.111739 |
| 2001 | 3.408605 |
| 2003 | 3.955374 |
| 2004 | 3.481716 |
| 2005 | 3.399557 |
| 2006 | 3.193743 |
| 2007 | 3.731619 |
| 2008 | 3.503981 |
| 2009 | 3.355240 |
| 2010 | 3.941205 |
| 2011 | 3.478097 |
| 2012 | 3.508195 |
| 2013 | 4.184425 |
| 2014 | 4.134220 |
| 2015 | 3.151142 |
| 2017 | 4.261683 |
| 2018 | 3.195918 |
| 2019 | 3.597782 |
| 2020 | 3.760857 |
| 2021 | 3.464185 |
ggplot(spring_standard_dev_all_378_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 378 average spring temperatures for water years 1986-2021
spring_sd_mk_378_ad <- mk.test(spring_standard_dev_all_378_ad$sd_2)
print(spring_sd_mk_378_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_378_ad$sd_2
## z = 0.91726, n = 27, p-value = 0.359
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 45.0000000 2301.0000000 0.1282051
spring_sd_sens_378_ad <- sens.slope(spring_standard_dev_all_378_ad$sd_2)
print(spring_sd_sens_378_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_378_ad$sd_2
## z = 0.91726, n = 27, p-value = 0.359
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01536871 0.02944544
## sample estimates:
## Sen's slope
## 0.007604482
Fall
fall_standard_dev_all_378_ad <- standard_dev_378_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_378_ad <- fall_standard_dev_all_378_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_378_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.146701 |
| 1990 | 3.368817 |
| 1991 | 3.532874 |
| 1992 | 4.129006 |
| 1997 | 3.689817 |
| 1998 | 3.343434 |
| 1999 | 3.308209 |
| 2000 | 3.472583 |
| 2001 | 2.929131 |
| 2003 | 2.772175 |
| 2004 | 4.098027 |
| 2005 | 2.531244 |
| 2006 | 3.879968 |
| 2007 | 3.400007 |
| 2008 | 3.415639 |
| 2009 | 3.289946 |
| 2010 | 3.900149 |
| 2011 | 2.973635 |
| 2012 | 3.017688 |
| 2013 | 3.356596 |
| 2014 | 3.612165 |
| 2015 | 3.072767 |
| 2017 | 3.975535 |
| 2018 | 3.463087 |
| 2019 | 3.568716 |
| 2020 | 5.544390 |
| 2021 | 4.071006 |
ggplot(fall_standard_dev_all_378_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 378 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_378_ad <- mk.test(fall_standard_dev_all_378_ad$sd_2)
print(fall_sd_mk_378_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_378_ad$sd_2
## z = 1.084, n = 27, p-value = 0.2783
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 53.0000000 2301.0000000 0.1509972
fall_sd_sens_378_ad <- sens.slope(fall_standard_dev_all_378_ad$sd_2)
print(fall_sd_sens_378_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_378_ad$sd_2
## z = 1.084, n = 27, p-value = 0.2783
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01036929 0.03886043
## sample estimates:
## Sen's slope
## 0.01311408
Morrisey 7/22/2005
snotel_408 <- SNOTEL_yampa_area %>%
filter(site_id == "408")
#str(snotel_408) # check the date, usually a character.
snotel_408$Date <- as.Date(snotel_408$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_408_clean <- snotel_408 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_408_clean <- snotel_408_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_408_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_408_clean <- snotel_408_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40)# %>%
#filter(temperature_mean < 25)
ggplot(snotel_408_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_408_cull_count <- snotel_408_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_408_cull_count
# filtering for too few observations in a year
snotel_408_cull_count_days <- snotel_408_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_408_cull_count_days
## # A tibble: 8 x 2
## # Groups: waterYear [8]
## waterYear n
## <dbl> <int>
## 1 1981 343
## 2 1983 317
## 3 1984 234
## 4 1985 195
## 5 1986 336
## 6 1987 298
## 7 1994 272
## 8 2002 347
snotel_408_clean_culled <- snotel_408_clean %>%
filter(waterYear > "1987" & waterYear != "1993" & waterYear != "1994" & waterYear != "2002")# & waterYear != "1985" & waterYear != "1986" & waterYear != "1987" & waterYear != "1994" & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_408_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Culling WY 1986 & 1993 as well.
ggplot(snotel_408_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_408_xts <- xts(snotel_408_clean_culled$temperature_mean, order.by = snotel_408_clean_culled$Date)
dygraph(temp_408_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
snotel_408_clean_culled <- snotel_408_clean_culled %>%
filter(temperature_mean > -30)
temp_408_xts <- xts(snotel_408_clean_culled$temperature_mean, order.by = snotel_408_clean_culled$Date)
dygraph(temp_408_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
snotel_408_adjusted <- snotel_408_clean_culled %>%
mutate(temp_ad = if_else(Date < "2005-07-22", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_408 <- snotel_408_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_408 <- yearly_wy_aver_408 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(temperature_mean))
#average mean temperature by day for the period of record:
daily_wy_aver_408 <- daily_wy_aver_408 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_408$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_408 <-daily_wy_aver_408 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_408$date_temp <- signif(daily_wy_aver2_408$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_408, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_408 <- daily_wy_aver_408 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
#detrend check:
detrend_check <- standard_dev_408 %>%
filter(waterYear == 2000)
#Testing:
ggplot(detrend_check, aes(x = waterDay, y = residual))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_all_408 <- standard_dev_408 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_408 <- standard_dev_all_408 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_408 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 4.122196 |
| 1989 | 4.224835 |
| 1990 | 3.532619 |
| 1991 | 3.912811 |
| 1992 | 3.818307 |
| 1995 | 3.854523 |
| 1996 | 3.890789 |
| 1997 | 3.911970 |
| 1998 | 3.624131 |
| 1999 | 3.893187 |
| 2000 | 3.713913 |
| 2001 | 3.755341 |
| 2003 | 3.603353 |
| 2004 | 3.901334 |
| 2005 | 3.505008 |
| 2006 | 3.862466 |
| 2007 | 3.764506 |
| 2008 | 3.618292 |
| 2009 | 3.658604 |
| 2010 | 3.618734 |
| 2011 | 3.667218 |
| 2012 | 3.498434 |
| 2013 | 3.927084 |
| 2014 | 3.637173 |
| 2015 | 3.865239 |
| 2016 | 3.367491 |
| 2017 | 4.108813 |
| 2018 | 3.452191 |
| 2019 | 3.546643 |
| 2020 | 3.934865 |
| 2021 | 3.594691 |
| 2022 | 3.887378 |
ggplot(standard_dev_all_408, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 408 average temperatures for water years 2005-2021
sd_mk_408 <- mk.test(standard_dev_all_408$sd_2)
print(sd_mk_408)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_408$sd_2
## z = -1.8, n = 32, p-value = 0.07186
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -112.0000000 3802.6666667 -0.2258065
sd_sens_408 <- sens.slope(standard_dev_all_408$sd_2)
print(sd_sens_408)
##
## Sen's slope
##
## data: standard_dev_all_408$sd_2
## z = -1.8, n = 32, p-value = 0.07186
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.0178517126 0.0007511908
## sample estimates:
## Sen's slope
## -0.009022314
#using the clean culled df:
#average water year temperature
yearly_wy_aver_408_ad <- snotel_408_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_408_ad <- yearly_wy_aver_408_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_408_ad <- daily_wy_aver_408_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_408_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_408_ad <-daily_wy_aver_408_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_408_ad$date_temp_ad <- signif(daily_wy_aver2_408_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_408_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_408_ad <- daily_wy_aver_408_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_408_ad <- standard_dev_408_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_408_ad <- standard_dev_all_408_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_408_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 3.850953 |
| 1989 | 3.996876 |
| 1990 | 3.330601 |
| 1991 | 3.726679 |
| 1992 | 3.669064 |
| 1995 | 3.666226 |
| 1996 | 3.689966 |
| 1997 | 3.722851 |
| 1998 | 3.379176 |
| 1999 | 3.744324 |
| 2000 | 3.502298 |
| 2001 | 3.481885 |
| 2003 | 3.367334 |
| 2004 | 3.706363 |
| 2005 | 3.377878 |
| 2006 | 3.865469 |
| 2007 | 3.784549 |
| 2008 | 3.644975 |
| 2009 | 3.609154 |
| 2010 | 3.636002 |
| 2011 | 3.660927 |
| 2012 | 3.513289 |
| 2013 | 3.958862 |
| 2014 | 3.617062 |
| 2015 | 3.800511 |
| 2016 | 3.366825 |
| 2017 | 4.065810 |
| 2018 | 3.424283 |
| 2019 | 3.561106 |
| 2020 | 3.962227 |
| 2021 | 3.622561 |
| 2022 | 3.888948 |
ggplot(standard_dev_all_408_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 408 average temperatures for water years 1986-2021
sd_mk_408_ad <- mk.test(standard_dev_all_408_ad$sd_2)
print(sd_mk_408_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_408_ad$sd_2
## z = 0.081082, n = 32, p-value = 0.9354
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 6.000000e+00 3.802667e+03 1.209677e-02
sd_sens_408_ad <- sens.slope(standard_dev_all_408_ad$sd_2)
print(sd_sens_408_ad)
##
## Sen's slope
##
## data: standard_dev_all_408_ad$sd_2
## z = 0.081082, n = 32, p-value = 0.9354
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.007237353 0.010756670
## sample estimates:
## Sen's slope
## 0.0009834684
summer_standard_dev_all_408 <- standard_dev_408 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_408 <- summer_standard_dev_all_408 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_408 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 2.160058 |
| 1989 | 3.008387 |
| 1990 | 2.733971 |
| 1991 | 2.409098 |
| 1992 | 2.549817 |
| 1995 | 3.208616 |
| 1996 | 1.630178 |
| 1997 | 2.159624 |
| 1998 | 3.030893 |
| 1999 | 1.872728 |
| 2000 | 2.406849 |
| 2001 | 2.827944 |
| 2003 | 2.775887 |
| 2004 | 2.802336 |
| 2005 | 2.735618 |
| 2006 | 2.408819 |
| 2007 | 2.215970 |
| 2008 | 2.558499 |
| 2009 | 2.142990 |
| 2010 | 2.171074 |
| 2011 | 1.985865 |
| 2012 | 2.183402 |
| 2013 | 2.179981 |
| 2014 | 2.111047 |
| 2015 | 2.225452 |
| 2016 | 2.085728 |
| 2017 | 1.970802 |
| 2018 | 2.192960 |
| 2019 | 2.410520 |
| 2020 | 2.454214 |
| 2021 | 2.777513 |
| 2022 | 2.159458 |
ggplot(summer_standard_dev_all_408, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 408 average summer temperatures for water years 2005-2021
summer_sd_mk_408 <- mk.test(summer_standard_dev_all_408$sd_2)
print(summer_sd_mk_408)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_408$sd_2
## z = -1.6379, n = 32, p-value = 0.1015
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -102.0000000 3802.6666667 -0.2056452
summer_sd_sens_408 <- sens.slope(summer_standard_dev_all_408$sd_2)
print(summer_sd_sens_408)
##
## Sen's slope
##
## data: summer_standard_dev_all_408$sd_2
## z = -1.6379, n = 32, p-value = 0.1015
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.0285029383 0.0009541897
## sample estimates:
## Sen's slope
## -0.01383851
Winter
winter_standard_dev_all_408 <- standard_dev_408 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_408 <- winter_standard_dev_all_408 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_408 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 4.680675 |
| 1989 | 4.973300 |
| 1990 | 4.039090 |
| 1991 | 4.634553 |
| 1992 | 3.838325 |
| 1995 | 4.621117 |
| 1996 | 4.536271 |
| 1997 | 4.561342 |
| 1998 | 4.041858 |
| 1999 | 4.581090 |
| 2000 | 4.077551 |
| 2001 | 4.030738 |
| 2003 | 3.960560 |
| 2004 | 4.319515 |
| 2005 | 4.197485 |
| 2006 | 4.636681 |
| 2007 | 4.627002 |
| 2008 | 4.199476 |
| 2009 | 4.398940 |
| 2010 | 4.095228 |
| 2011 | 4.617140 |
| 2012 | 4.121452 |
| 2013 | 4.792809 |
| 2014 | 4.110372 |
| 2015 | 4.813936 |
| 2016 | 4.119557 |
| 2017 | 4.891639 |
| 2018 | 4.056260 |
| 2019 | 4.052562 |
| 2020 | 3.806438 |
| 2021 | 3.872154 |
| 2022 | 4.699146 |
ggplot(winter_standard_dev_all_408, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 408 average winter temperatures for water years 2005-2021
winter_sd_mk_408 <- mk.test(winter_standard_dev_all_408$sd_2)
print(winter_sd_mk_408)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_408$sd_2
## z = -0.76217, n = 32, p-value = 0.446
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -48.00000000 3802.66666667 -0.09677419
winter_sd_sens_408 <- sens.slope(winter_standard_dev_all_408$sd_2)
print(winter_sd_sens_408)
##
## Sen's slope
##
## data: winter_standard_dev_all_408$sd_2
## z = -0.76217, n = 32, p-value = 0.446
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.024067288 0.005552547
## sample estimates:
## Sen's slope
## -0.007399084
Summer
summer_standard_dev_all_408_ad <- standard_dev_408_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_408_ad <- summer_standard_dev_all_408_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_408_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 1.951149 |
| 1989 | 2.691408 |
| 1990 | 2.468482 |
| 1991 | 2.173205 |
| 1992 | 2.296903 |
| 1995 | 2.882685 |
| 1996 | 1.459462 |
| 1997 | 1.948304 |
| 1998 | 2.703351 |
| 1999 | 1.674073 |
| 2000 | 2.171356 |
| 2001 | 2.547978 |
| 2003 | 2.453149 |
| 2004 | 2.523349 |
| 2005 | 2.479412 |
| 2006 | 2.387287 |
| 2007 | 2.233782 |
| 2008 | 2.581903 |
| 2009 | 2.162547 |
| 2010 | 2.166643 |
| 2011 | 1.988990 |
| 2012 | 2.156846 |
| 2013 | 2.151757 |
| 2014 | 2.103464 |
| 2015 | 2.191604 |
| 2016 | 2.052962 |
| 2017 | 1.940250 |
| 2018 | 2.174709 |
| 2019 | 2.430984 |
| 2020 | 2.442469 |
| 2021 | 2.744131 |
| 2022 | 2.151181 |
ggplot(summer_standard_dev_all_408_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 408 average summer temperatures for water years 1986-2021
summer_sd_mk_408_ad <- mk.test(summer_standard_dev_all_408_ad$sd_2)
print(summer_sd_mk_408_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_408_ad$sd_2
## z = -0.8919, n = 32, p-value = 0.3724
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -56.0000000 3802.6666667 -0.1129032
summer_sd_sens_408_ad <- sens.slope(summer_standard_dev_all_408_ad$sd_2)
print(summer_sd_sens_408_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_408_ad$sd_2
## z = -0.8919, n = 32, p-value = 0.3724
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.017755194 0.008453193
## sample estimates:
## Sen's slope
## -0.004192841
Winter
winter_standard_dev_all_408_ad <- standard_dev_408_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_408_ad <- winter_standard_dev_all_408_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_408_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 4.570065 |
| 1989 | 4.851524 |
| 1990 | 3.911990 |
| 1991 | 4.548088 |
| 1992 | 3.740151 |
| 1995 | 4.454623 |
| 1996 | 4.397209 |
| 1997 | 4.411526 |
| 1998 | 3.909249 |
| 1999 | 4.427019 |
| 2000 | 3.900180 |
| 2001 | 3.925081 |
| 2003 | 3.830604 |
| 2004 | 4.157215 |
| 2005 | 4.075941 |
| 2006 | 4.636058 |
| 2007 | 4.635832 |
| 2008 | 4.205165 |
| 2009 | 4.395215 |
| 2010 | 4.098594 |
| 2011 | 4.612482 |
| 2012 | 4.123831 |
| 2013 | 4.790447 |
| 2014 | 4.108958 |
| 2015 | 4.809684 |
| 2016 | 4.115105 |
| 2017 | 4.906039 |
| 2018 | 4.048838 |
| 2019 | 4.039119 |
| 2020 | 3.806029 |
| 2021 | 3.863195 |
| 2022 | 4.696385 |
ggplot(winter_standard_dev_all_408_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 408 average winter temperatures for water years 1986-2021
winter_sd_mk_408_ad <- mk.test(winter_standard_dev_all_408_ad$sd_2)
print(winter_sd_mk_408_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_408_ad$sd_2
## z = -0.24325, n = 32, p-value = 0.8078
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -16.00000000 3802.66666667 -0.03225806
winter_sd_sens_408_ad <- sens.slope(winter_standard_dev_all_408_ad$sd_2)
print(winter_sd_sens_408_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_408_ad$sd_2
## z = -0.24325, n = 32, p-value = 0.8078
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01822521 0.01275575
## sample estimates:
## Sen's slope
## -0.001834189
spring_standard_dev_all_408 <- standard_dev_408 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_408 <- spring_standard_dev_all_408 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_408 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 4.025326 |
| 1989 | 4.187649 |
| 1990 | 3.169213 |
| 1991 | 3.931048 |
| 1992 | 3.316353 |
| 1995 | 2.858090 |
| 1996 | 3.930483 |
| 1997 | 4.079687 |
| 1998 | 3.011379 |
| 1999 | 4.204134 |
| 2000 | 4.312522 |
| 2001 | 3.756611 |
| 2003 | 4.197188 |
| 2004 | 3.802792 |
| 2005 | 3.259969 |
| 2006 | 3.209573 |
| 2007 | 3.581505 |
| 2008 | 3.572901 |
| 2009 | 3.273149 |
| 2010 | 3.743885 |
| 2011 | 3.278303 |
| 2012 | 3.690985 |
| 2013 | 4.189328 |
| 2014 | 4.102056 |
| 2015 | 3.109852 |
| 2016 | 3.231096 |
| 2017 | 4.074633 |
| 2018 | 3.004628 |
| 2019 | 3.532025 |
| 2020 | 3.913512 |
| 2021 | 3.537893 |
| 2022 | 4.112946 |
ggplot(spring_standard_dev_all_408, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 408 average spring temperatures for water years 2005-2021
spring_sd_mk_408 <- mk.test(spring_standard_dev_all_408$sd_2)
print(spring_sd_mk_408)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_408$sd_2
## z = -0.56758, n = 32, p-value = 0.5703
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -36.00000000 3802.66666667 -0.07258065
spring_sd_sens_408 <- sens.slope(spring_standard_dev_all_408$sd_2)
print(spring_sd_sens_408)
##
## Sen's slope
##
## data: spring_standard_dev_all_408$sd_2
## z = -0.56758, n = 32, p-value = 0.5703
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02240538 0.01432186
## sample estimates:
## Sen's slope
## -0.003873105
Fall
fall_standard_dev_all_408 <- standard_dev_408 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_408 <- fall_standard_dev_all_408 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_408 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 3.768321 |
| 1989 | 2.966066 |
| 1990 | 3.540577 |
| 1991 | 3.633477 |
| 1992 | 5.401512 |
| 1995 | 3.306605 |
| 1996 | 4.289173 |
| 1997 | 4.026644 |
| 1998 | 3.716425 |
| 1999 | 3.326328 |
| 2000 | 3.692913 |
| 2001 | 3.313727 |
| 2003 | 2.672557 |
| 2004 | 4.006060 |
| 2005 | 2.507946 |
| 2006 | 3.743950 |
| 2007 | 3.145367 |
| 2008 | 3.405140 |
| 2009 | 3.230853 |
| 2010 | 3.991380 |
| 2011 | 2.959319 |
| 2012 | 2.942060 |
| 2013 | 3.139594 |
| 2014 | 3.622293 |
| 2015 | 3.127705 |
| 2016 | 2.707995 |
| 2017 | 3.978752 |
| 2018 | 3.563991 |
| 2019 | 3.630854 |
| 2020 | 5.363935 |
| 2021 | 3.926278 |
| 2022 | 3.282654 |
ggplot(fall_standard_dev_all_408, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 408 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_408 <- mk.test(fall_standard_dev_all_408$sd_2)
print(fall_sd_mk_408)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_408$sd_2
## z = -0.79461, n = 32, p-value = 0.4268
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -50.0000000 3802.6666667 -0.1008065
fall_sd_sens_408 <- sens.slope(fall_standard_dev_all_408$sd_2)
print(fall_sd_sens_408)
##
## Sen's slope
##
## data: fall_standard_dev_all_408$sd_2
## z = -0.79461, n = 32, p-value = 0.4268
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02985931 0.01564404
## sample estimates:
## Sen's slope
## -0.005872711
Spring
spring_standard_dev_all_408_ad <- standard_dev_408_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_408_ad <- spring_standard_dev_all_408_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_408_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 3.714092 |
| 1989 | 3.852431 |
| 1990 | 2.960315 |
| 1991 | 3.628927 |
| 1992 | 3.065046 |
| 1995 | 2.682351 |
| 1996 | 3.629319 |
| 1997 | 3.811964 |
| 1998 | 2.723386 |
| 1999 | 3.901887 |
| 2000 | 3.959064 |
| 2001 | 3.459362 |
| 2003 | 3.836636 |
| 2004 | 3.510426 |
| 2005 | 3.001941 |
| 2006 | 3.194989 |
| 2007 | 3.569337 |
| 2008 | 3.598630 |
| 2009 | 3.293648 |
| 2010 | 3.756467 |
| 2011 | 3.275085 |
| 2012 | 3.656352 |
| 2013 | 4.218834 |
| 2014 | 4.112872 |
| 2015 | 3.055315 |
| 2016 | 3.214971 |
| 2017 | 4.050030 |
| 2018 | 3.024961 |
| 2019 | 3.480246 |
| 2020 | 3.919687 |
| 2021 | 3.535895 |
| 2022 | 4.103607 |
ggplot(spring_standard_dev_all_408_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 408 average spring temperatures for water years 1986-2021
spring_sd_mk_408_ad <- mk.test(spring_standard_dev_all_408_ad$sd_2)
print(spring_sd_mk_408_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_408_ad$sd_2
## z = 0.9892, n = 32, p-value = 0.3226
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 62.000 3802.667 0.125
spring_sd_sens_408_ad <- sens.slope(spring_standard_dev_all_408_ad$sd_2)
print(spring_sd_sens_408_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_408_ad$sd_2
## z = 0.9892, n = 32, p-value = 0.3226
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01076220 0.02557361
## sample estimates:
## Sen's slope
## 0.01089377
Fall
fall_standard_dev_all_408_ad <- standard_dev_408_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_408_ad <- fall_standard_dev_all_408_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_408_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 3.500114 |
| 1989 | 2.779225 |
| 1990 | 3.190138 |
| 1991 | 3.369412 |
| 1992 | 5.046621 |
| 1995 | 3.013692 |
| 1996 | 3.974926 |
| 1997 | 3.701275 |
| 1998 | 3.344678 |
| 1999 | 3.126846 |
| 2000 | 3.420990 |
| 2001 | 3.033809 |
| 2003 | 2.452351 |
| 2004 | 3.740423 |
| 2005 | 2.316014 |
| 2006 | 3.667225 |
| 2007 | 3.189089 |
| 2008 | 3.348434 |
| 2009 | 3.220502 |
| 2010 | 4.031159 |
| 2011 | 2.936616 |
| 2012 | 2.957996 |
| 2013 | 3.160949 |
| 2014 | 3.642089 |
| 2015 | 3.067864 |
| 2016 | 2.654910 |
| 2017 | 3.931140 |
| 2018 | 3.578413 |
| 2019 | 3.660271 |
| 2020 | 5.431437 |
| 2021 | 3.930767 |
| 2022 | 3.317615 |
ggplot(fall_standard_dev_all_408_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 408 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_408_ad <- mk.test(fall_standard_dev_all_408_ad$sd_2)
print(fall_sd_mk_408_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_408_ad$sd_2
## z = 0.56758, n = 32, p-value = 0.5703
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 3.600000e+01 3.802667e+03 7.258065e-02
fall_sd_sens_408_ad <- sens.slope(fall_standard_dev_all_408_ad$sd_2)
print(fall_sd_sens_408_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_408_ad$sd_2
## z = 0.56758, n = 32, p-value = 0.5703
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01408452 0.02828833
## sample estimates:
## Sen's slope
## 0.008666756
Morrisey 6/23/2005
snotel_409 <- SNOTEL_yampa_area %>%
filter(site_id == "409")
#str(snotel_409) # check the date, usually a character.
snotel_409$Date <- as.Date(snotel_409$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_409_clean <- snotel_409 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_409_clean <- snotel_409_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_409_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_409_clean <- snotel_409_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -50) %>%
filter(temperature_mean < 40)
ggplot(snotel_409_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_409_cull_count <- snotel_409_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_409_cull_count
# filtering for too few observations in a year
snotel_409_cull_count_days <- snotel_409_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_409_cull_count_days
## # A tibble: 5 x 2
## # Groups: waterYear [5]
## waterYear n
## <dbl> <int>
## 1 1994 331
## 2 1995 190
## 3 2005 329
## 4 2019 348
## 5 2022 346
snotel_409_clean_culled <- snotel_409_clean %>%
filter(waterYear != "1994" & waterYear != "1995" & waterYear != "2005" & waterYear != "2019" & waterYear != "2022")# & waterYear != "1986" & waterYear != "1987" & waterYear != "1994" & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_409_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
ggplot(snotel_409_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_409_xts <- xts(snotel_409_clean_culled$temperature_mean, order.by = snotel_409_clean_culled$Date)
dygraph(temp_409_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_409_clean_culled <- snotel_409_clean_culled %>%
# filter(temperature_mean > -30)
#temp_409_xts <- xts(snotel_409_clean_culled$temperature_mean, order.by = snotel_409_clean_culled$Date)
#dygraph(temp_409_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
Morrisey 6/23/2005
snotel_409_adjusted <- snotel_409_clean_culled %>%
mutate(temp_ad = if_else(Date < "2005-06-23", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_409 <- snotel_409_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_409 <- yearly_wy_aver_409 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(temperature_mean))
#average mean temperature by day for the period of record:
daily_wy_aver_409 <- daily_wy_aver_409 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_409$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_409 <-daily_wy_aver_409 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_409$date_temp <- signif(daily_wy_aver2_409$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_409, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_409 <- daily_wy_aver_409 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_409 <- standard_dev_409 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_409 <- standard_dev_all_409 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_409 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.495972 |
| 1988 | 3.864837 |
| 1989 | 4.150756 |
| 1990 | 3.715419 |
| 1991 | 7.886567 |
| 1992 | 3.655020 |
| 1993 | 3.443175 |
| 1996 | 3.871778 |
| 1997 | 3.684240 |
| 1998 | 3.566451 |
| 1999 | 3.690634 |
| 2000 | 3.806945 |
| 2001 | 3.805078 |
| 2002 | 3.935441 |
| 2003 | 3.561320 |
| 2004 | 3.990949 |
| 2006 | 3.799208 |
| 2007 | 3.756201 |
| 2008 | 3.734920 |
| 2009 | 3.575439 |
| 2010 | 3.477648 |
| 2011 | 3.895182 |
| 2012 | 3.326089 |
| 2013 | 3.896199 |
| 2014 | 3.563991 |
| 2015 | 3.704594 |
| 2016 | 3.428127 |
| 2017 | 3.800029 |
| 2018 | 3.317697 |
| 2020 | 3.674904 |
| 2021 | 3.663614 |
ggplot(standard_dev_all_409, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 409 average temperatures for water years 2005-2021
sd_mk_409 <- mk.test(standard_dev_all_409$sd_2)
print(sd_mk_409)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_409$sd_2
## z = -1.5977, n = 31, p-value = 0.1101
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -95.0000000 3461.6666667 -0.2043011
sd_sens_409 <- sens.slope(standard_dev_all_409$sd_2)
print(sd_sens_409)
##
## Sen's slope
##
## data: standard_dev_all_409$sd_2
## z = -1.5977, n = 31, p-value = 0.1101
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.017215984 0.001425571
## sample estimates:
## Sen's slope
## -0.00751559
#using the clean culled df:
#average water year temperature
yearly_wy_aver_409_ad <- snotel_409_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_409_ad <- yearly_wy_aver_409_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_409_ad <- daily_wy_aver_409_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_409_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_409_ad <-daily_wy_aver_409_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_409_ad$date_temp_ad <- signif(daily_wy_aver2_409_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_409_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_409_ad <- daily_wy_aver_409_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_409_ad <- standard_dev_409_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_409_ad <- standard_dev_all_409_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_409_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.266770 |
| 1988 | 3.561893 |
| 1989 | 3.882288 |
| 1990 | 3.451808 |
| 1991 | 7.402560 |
| 1992 | 3.437534 |
| 1993 | 3.208576 |
| 1996 | 3.608124 |
| 1997 | 3.447235 |
| 1998 | 3.267783 |
| 1999 | 3.513167 |
| 2000 | 3.521064 |
| 2001 | 3.492918 |
| 2002 | 3.583401 |
| 2003 | 3.261139 |
| 2004 | 3.728286 |
| 2006 | 3.784595 |
| 2007 | 3.779490 |
| 2008 | 3.780985 |
| 2009 | 3.542117 |
| 2010 | 3.511838 |
| 2011 | 3.910483 |
| 2012 | 3.349866 |
| 2013 | 3.931896 |
| 2014 | 3.545831 |
| 2015 | 3.622791 |
| 2016 | 3.429398 |
| 2017 | 3.772145 |
| 2018 | 3.294426 |
| 2020 | 3.730141 |
| 2021 | 3.707606 |
ggplot(standard_dev_all_409_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 409 average temperatures for water years 1986-2021
sd_mk_409_ad <- mk.test(standard_dev_all_409_ad$sd_2)
print(sd_mk_409_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_409_ad$sd_2
## z = 1.2237, n = 31, p-value = 0.221
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 73.0000000 3461.6666667 0.1569892
sd_sens_409_ad <- sens.slope(standard_dev_all_409_ad$sd_2)
print(sd_sens_409_ad)
##
## Sen's slope
##
## data: standard_dev_all_409_ad$sd_2
## z = 1.2237, n = 31, p-value = 0.221
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.004188748 0.015233958
## sample estimates:
## Sen's slope
## 0.006314099
summer_standard_dev_all_409 <- standard_dev_409 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_409 <- summer_standard_dev_all_409 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_409 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.513983 |
| 1988 | 2.371119 |
| 1989 | 2.775714 |
| 1990 | 2.953491 |
| 1991 | 2.526155 |
| 1992 | 2.799705 |
| 1993 | 2.775161 |
| 1996 | 2.038989 |
| 1997 | 2.215588 |
| 1998 | 3.035376 |
| 1999 | 2.307161 |
| 2000 | 2.391550 |
| 2001 | 2.827788 |
| 2002 | 2.559134 |
| 2003 | 2.605412 |
| 2004 | 2.536830 |
| 2006 | 2.418785 |
| 2007 | 1.909282 |
| 2008 | 2.399402 |
| 2009 | 2.273527 |
| 2010 | 2.474689 |
| 2011 | 2.174690 |
| 2012 | 2.004796 |
| 2013 | 2.226754 |
| 2014 | 2.061020 |
| 2015 | 2.530912 |
| 2016 | 2.463450 |
| 2017 | 1.969965 |
| 2018 | 1.809538 |
| 2020 | 2.754058 |
| 2021 | 2.965355 |
ggplot(summer_standard_dev_all_409, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 409 average summer temperatures for water years 2005-2021
summer_sd_mk_409 <- mk.test(summer_standard_dev_all_409$sd_2)
print(summer_sd_mk_409)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_409$sd_2
## z = -1.8356, n = 31, p-value = 0.06641
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -109.0000000 3461.6666667 -0.2344086
summer_sd_sens_409 <- sens.slope(summer_standard_dev_all_409$sd_2)
print(summer_sd_sens_409)
##
## Sen's slope
##
## data: summer_standard_dev_all_409$sd_2
## z = -1.8356, n = 31, p-value = 0.06641
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.0315290069 0.0007443859
## sample estimates:
## Sen's slope
## -0.01419181
Winter
winter_standard_dev_all_409 <- standard_dev_409 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_409 <- winter_standard_dev_all_409 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_409 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.000433 |
| 1988 | 4.239064 |
| 1989 | 4.883845 |
| 1990 | 4.233427 |
| 1991 | 9.596274 |
| 1992 | 3.502681 |
| 1993 | 3.733543 |
| 1996 | 4.356658 |
| 1997 | 4.073811 |
| 1998 | 3.812935 |
| 1999 | 3.988981 |
| 2000 | 4.348674 |
| 2001 | 4.040277 |
| 2002 | 4.400388 |
| 2003 | 3.648409 |
| 2004 | 4.635187 |
| 2006 | 4.472151 |
| 2007 | 4.662915 |
| 2008 | 4.406824 |
| 2009 | 4.132535 |
| 2010 | 3.606293 |
| 2011 | 4.927446 |
| 2012 | 3.816428 |
| 2013 | 4.849306 |
| 2014 | 3.804686 |
| 2015 | 4.066909 |
| 2016 | 4.125652 |
| 2017 | 4.352851 |
| 2018 | 4.002004 |
| 2020 | 3.568632 |
| 2021 | 3.928221 |
ggplot(winter_standard_dev_all_409, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 409 average winter temperatures for water years 2005-2021
winter_sd_mk_409 <- mk.test(winter_standard_dev_all_409$sd_2)
print(winter_sd_mk_409)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_409$sd_2
## z = -0.54389, n = 31, p-value = 0.5865
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -33.00000000 3461.66666667 -0.07096774
winter_sd_sens_409 <- sens.slope(winter_standard_dev_all_409$sd_2)
print(winter_sd_sens_409)
##
## Sen's slope
##
## data: winter_standard_dev_all_409$sd_2
## z = -0.54389, n = 31, p-value = 0.5865
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02394400 0.01553915
## sample estimates:
## Sen's slope
## -0.00531843
Summer
summer_standard_dev_all_409_ad <- standard_dev_409_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_409_ad <- summer_standard_dev_all_409_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_409_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.258912 |
| 1988 | 2.124527 |
| 1989 | 2.475856 |
| 1990 | 2.651125 |
| 1991 | 2.270811 |
| 1992 | 2.507199 |
| 1993 | 2.476143 |
| 1996 | 1.835387 |
| 1997 | 1.983664 |
| 1998 | 2.705591 |
| 1999 | 2.070868 |
| 2000 | 2.154186 |
| 2001 | 2.544216 |
| 2002 | 2.293948 |
| 2003 | 2.318762 |
| 2004 | 2.282365 |
| 2006 | 2.396638 |
| 2007 | 1.920747 |
| 2008 | 2.408611 |
| 2009 | 2.305728 |
| 2010 | 2.463024 |
| 2011 | 2.162252 |
| 2012 | 1.981025 |
| 2013 | 2.204215 |
| 2014 | 2.071051 |
| 2015 | 2.510782 |
| 2016 | 2.447829 |
| 2017 | 1.941966 |
| 2018 | 1.798619 |
| 2020 | 2.749133 |
| 2021 | 2.938145 |
ggplot(summer_standard_dev_all_409_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 409 average summer temperatures for water years 1986-2021
summer_sd_mk_409_ad <- mk.test(summer_standard_dev_all_409_ad$sd_2)
print(summer_sd_mk_409_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_409_ad$sd_2
## z = 0, n = 31, p-value = 1
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -1.000000e+00 3.461667e+03 -2.150538e-03
summer_sd_sens_409_ad <- sens.slope(summer_standard_dev_all_409_ad$sd_2)
print(summer_sd_sens_409_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_409_ad$sd_2
## z = 0, n = 31, p-value = 1
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01488390 0.01201328
## sample estimates:
## Sen's slope
## -0.0001884368
Winter
winter_standard_dev_all_409_ad <- standard_dev_409_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_409_ad <- winter_standard_dev_all_409_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_409_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.830066 |
| 1988 | 4.054246 |
| 1989 | 4.673597 |
| 1990 | 4.017393 |
| 1991 | 8.900135 |
| 1992 | 3.357188 |
| 1993 | 3.578167 |
| 1996 | 4.135939 |
| 1997 | 3.869866 |
| 1998 | 3.633500 |
| 1999 | 3.790833 |
| 2000 | 4.095631 |
| 2001 | 3.875873 |
| 2002 | 4.172906 |
| 2003 | 3.481961 |
| 2004 | 4.412031 |
| 2006 | 4.457990 |
| 2007 | 4.667686 |
| 2008 | 4.422968 |
| 2009 | 4.126597 |
| 2010 | 3.612716 |
| 2011 | 4.919049 |
| 2012 | 3.814114 |
| 2013 | 4.850979 |
| 2014 | 3.795075 |
| 2015 | 4.072789 |
| 2016 | 4.117712 |
| 2017 | 4.362361 |
| 2018 | 3.989836 |
| 2020 | 3.567499 |
| 2021 | 3.917901 |
ggplot(winter_standard_dev_all_409_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 409 average winter temperatures for water years 1986-2021
winter_sd_mk_409_ad <- mk.test(winter_standard_dev_all_409_ad$sd_2)
print(winter_sd_mk_409_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_409_ad$sd_2
## z = 0.33993, n = 31, p-value = 0.7339
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 2.100000e+01 3.461667e+03 4.516129e-02
winter_sd_sens_409_ad <- sens.slope(winter_standard_dev_all_409_ad$sd_2)
print(winter_sd_sens_409_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_409_ad$sd_2
## z = 0.33993, n = 31, p-value = 0.7339
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01540047 0.02592081
## sample estimates:
## Sen's slope
## 0.002927829
spring_standard_dev_all_409 <- standard_dev_409 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_409 <- spring_standard_dev_all_409 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_409 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.561579 |
| 1988 | 4.578729 |
| 1989 | 4.391870 |
| 1990 | 3.208584 |
| 1991 | 6.244185 |
| 1992 | 3.550952 |
| 1993 | 3.582567 |
| 1996 | 4.235865 |
| 1997 | 4.093757 |
| 1998 | 3.351975 |
| 1999 | 4.101267 |
| 2000 | 4.082095 |
| 2001 | 4.245291 |
| 2002 | 3.421203 |
| 2003 | 4.264453 |
| 2004 | 3.528981 |
| 2006 | 3.326359 |
| 2007 | 3.733242 |
| 2008 | 3.651164 |
| 2009 | 3.537388 |
| 2010 | 4.106611 |
| 2011 | 3.726744 |
| 2012 | 3.521956 |
| 2013 | 3.912197 |
| 2014 | 4.235522 |
| 2015 | 3.628131 |
| 2016 | 3.315573 |
| 2017 | 4.173378 |
| 2018 | 3.256959 |
| 2020 | 3.241042 |
| 2021 | 3.286197 |
ggplot(spring_standard_dev_all_409, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 409 average spring temperatures for water years 2005-2021
spring_sd_mk_409 <- mk.test(spring_standard_dev_all_409$sd_2)
print(spring_sd_mk_409)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_409$sd_2
## z = -2.0396, n = 31, p-value = 0.04139
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -121.0000000 3461.6666667 -0.2602151
spring_sd_sens_409 <- sens.slope(spring_standard_dev_all_409$sd_2)
print(spring_sd_sens_409)
##
## Sen's slope
##
## data: spring_standard_dev_all_409$sd_2
## z = -2.0396, n = 31, p-value = 0.04139
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.0408429507 -0.0009688711
## sample estimates:
## Sen's slope
## -0.01584774
Fall
fall_standard_dev_all_409 <- standard_dev_409 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_409 <- fall_standard_dev_all_409 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_409 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.184045 |
| 1988 | 3.298807 |
| 1989 | 2.587151 |
| 1990 | 3.907058 |
| 1991 | 3.548340 |
| 1992 | 4.252594 |
| 1993 | 3.093285 |
| 1996 | 4.105283 |
| 1997 | 4.033953 |
| 1998 | 3.632605 |
| 1999 | 3.219463 |
| 2000 | 3.691943 |
| 2001 | 3.332071 |
| 2002 | 3.552847 |
| 2003 | 3.322550 |
| 2004 | 4.308047 |
| 2006 | 3.481035 |
| 2007 | 3.175935 |
| 2008 | 3.509452 |
| 2009 | 3.520669 |
| 2010 | 3.763856 |
| 2011 | 2.793876 |
| 2012 | 3.174494 |
| 2013 | 3.108330 |
| 2014 | 3.844918 |
| 2015 | 2.955638 |
| 2016 | 2.674197 |
| 2017 | 3.812446 |
| 2018 | 3.190437 |
| 2020 | 4.956401 |
| 2021 | 4.020098 |
ggplot(fall_standard_dev_all_409, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 409 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_409 <- mk.test(fall_standard_dev_all_409$sd_2)
print(fall_sd_mk_409)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_409$sd_2
## z = -0.13597, n = 31, p-value = 0.8918
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -9.00000000 3461.66666667 -0.01935484
fall_sd_sens_409 <- sens.slope(fall_standard_dev_all_409$sd_2)
print(fall_sd_sens_409)
##
## Sen's slope
##
## data: fall_standard_dev_all_409$sd_2
## z = -0.13597, n = 31, p-value = 0.8918
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02414931 0.02534549
## sample estimates:
## Sen's slope
## -0.001612536
Spring
spring_standard_dev_all_409_ad <- standard_dev_409_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_409_ad <- spring_standard_dev_all_409_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_409_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.288331 |
| 1988 | 4.193344 |
| 1989 | 4.023275 |
| 1990 | 2.958716 |
| 1991 | 5.715099 |
| 1992 | 3.266312 |
| 1993 | 3.268688 |
| 1996 | 3.843431 |
| 1997 | 3.751459 |
| 1998 | 3.030397 |
| 1999 | 3.753865 |
| 2000 | 3.702838 |
| 2001 | 3.871132 |
| 2002 | 3.112417 |
| 2003 | 3.852353 |
| 2004 | 3.218856 |
| 2006 | 3.329624 |
| 2007 | 3.730793 |
| 2008 | 3.655849 |
| 2009 | 3.566359 |
| 2010 | 4.108949 |
| 2011 | 3.713716 |
| 2012 | 3.506299 |
| 2013 | 3.938093 |
| 2014 | 4.244232 |
| 2015 | 3.573442 |
| 2016 | 3.293115 |
| 2017 | 4.141244 |
| 2018 | 3.279234 |
| 2020 | 3.274358 |
| 2021 | 3.273461 |
ggplot(spring_standard_dev_all_409_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 409 average spring temperatures for water years 1986-2021
spring_sd_mk_409_ad <- mk.test(spring_standard_dev_all_409_ad$sd_2)
print(spring_sd_mk_409_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_409_ad$sd_2
## z = -0.30594, n = 31, p-value = 0.7597
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -19.00000000 3461.66666667 -0.04086022
spring_sd_sens_409_ad <- sens.slope(spring_standard_dev_all_409_ad$sd_2)
print(spring_sd_sens_409_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_409_ad$sd_2
## z = -0.30594, n = 31, p-value = 0.7597
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02398139 0.01463308
## sample estimates:
## Sen's slope
## -0.003295996
Fall
fall_standard_dev_all_409_ad <- standard_dev_409_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_409_ad <- fall_standard_dev_all_409_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_409_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.907036 |
| 1988 | 3.028108 |
| 1989 | 2.402159 |
| 1990 | 3.499623 |
| 1991 | 3.282029 |
| 1992 | 3.907608 |
| 1993 | 2.842849 |
| 1996 | 3.774849 |
| 1997 | 3.656130 |
| 1998 | 3.269977 |
| 1999 | 2.957556 |
| 2000 | 3.376798 |
| 2001 | 2.963503 |
| 2002 | 3.274083 |
| 2003 | 3.007121 |
| 2004 | 3.967859 |
| 2006 | 3.422927 |
| 2007 | 3.227650 |
| 2008 | 3.470006 |
| 2009 | 3.499157 |
| 2010 | 3.829702 |
| 2011 | 2.802195 |
| 2012 | 3.182752 |
| 2013 | 3.103533 |
| 2014 | 3.880898 |
| 2015 | 2.906173 |
| 2016 | 2.647013 |
| 2017 | 3.757830 |
| 2018 | 3.183640 |
| 2020 | 5.013153 |
| 2021 | 4.037099 |
ggplot(fall_standard_dev_all_409_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 409 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_409_ad <- mk.test(fall_standard_dev_all_409_ad$sd_2)
print(fall_sd_mk_409_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_409_ad$sd_2
## z = 1.1897, n = 31, p-value = 0.2341
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 71.0000000 3461.6666667 0.1526882
fall_sd_sens_409_ad <- sens.slope(fall_standard_dev_all_409_ad$sd_2)
print(fall_sd_sens_409_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_409_ad$sd_2
## z = 1.1897, n = 31, p-value = 0.2341
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.006029522 0.034792793
## sample estimates:
## Sen's slope
## 0.01375853
Morrisey 7/21/2005
snotel_426 <- SNOTEL_yampa_area %>%
filter(site_id == "426")
#str(snotel_426) # check the date, usually a character.
snotel_426$Date <- as.Date(snotel_426$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_426_clean <- snotel_426 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_426_clean <- snotel_426_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_426_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_426_clean <- snotel_426_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -50) %>%
filter(temperature_mean < 40)
ggplot(snotel_426_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_426_cull_count <- snotel_426_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_426_cull_count
# filtering for too few observations in a year
snotel_426_cull_count_days <- snotel_426_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_426_cull_count_days
## # A tibble: 2 x 2
## # Groups: waterYear [2]
## waterYear n
## <dbl> <int>
## 1 2009 340
## 2 2021 349
snotel_426_clean_culled <- snotel_426_clean %>%
filter(waterYear != "2009" & waterYear != "2021")# & waterYear != "2005" & waterYear != "2019" & waterYear != "2022")# & waterYear != "1986" & waterYear != "1987" & waterYear != "1994" & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_426_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
ggplot(snotel_426_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_426_xts <- xts(snotel_426_clean_culled$temperature_mean, order.by = snotel_426_clean_culled$Date)
dygraph(temp_426_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_426_clean_culled <- snotel_426_clean_culled %>%
# filter(temperature_mean > -30)
#temp_426_xts <- xts(snotel_426_clean_culled$temperature_mean, order.by = snotel_426_clean_culled$Date)
#dygraph(temp_426_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
snotel_426_adjusted <- snotel_426_clean_culled %>%
mutate(temp_ad = if_else(Date < "2005-07-21", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_426 <- snotel_426_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_426 <- yearly_wy_aver_426 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(temperature_mean))
#average mean temperature by day for the period of record:
daily_wy_aver_426 <- daily_wy_aver_426 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_426$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_426 <-daily_wy_aver_426 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_426$date_temp <- signif(daily_wy_aver2_426$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_426, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_426 <- daily_wy_aver_426 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_426 <- standard_dev_426 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_426 <- standard_dev_all_426 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_426 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.835192 |
| 1988 | 6.688853 |
| 1989 | 5.077404 |
| 1990 | 3.898866 |
| 1991 | 4.207908 |
| 1992 | 3.890922 |
| 1993 | 3.892243 |
| 1994 | 3.927671 |
| 1995 | 4.062616 |
| 1996 | 4.066972 |
| 1997 | 4.132857 |
| 1998 | 3.722134 |
| 1999 | 4.072191 |
| 2000 | 3.862336 |
| 2001 | 3.840951 |
| 2002 | 4.151335 |
| 2003 | 3.924485 |
| 2004 | 4.083801 |
| 2005 | 3.670746 |
| 2006 | 4.084252 |
| 2007 | 3.970941 |
| 2008 | 3.872448 |
| 2010 | 3.840234 |
| 2011 | 3.853667 |
| 2012 | 3.626466 |
| 2013 | 4.096949 |
| 2014 | 3.902677 |
| 2015 | 3.917633 |
| 2016 | 3.635992 |
| 2017 | 4.356405 |
| 2018 | 3.785995 |
| 2019 | 3.760199 |
| 2020 | 4.137484 |
| 2022 | 4.114320 |
ggplot(standard_dev_all_426, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 426 average temperatures for water years 2005-2021
sd_mk_426 <- mk.test(standard_dev_all_426$sd_2)
print(sd_mk_426)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_426$sd_2
## z = -1.0674, n = 34, p-value = 0.2858
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -73.0000000 4550.3333333 -0.1301248
sd_sens_426 <- sens.slope(standard_dev_all_426$sd_2)
print(sd_sens_426)
##
## Sen's slope
##
## data: standard_dev_all_426$sd_2
## z = -1.0674, n = 34, p-value = 0.2858
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01404196 0.00210359
## sample estimates:
## Sen's slope
## -0.004490654
#using the clean culled df:
#average water year temperature
yearly_wy_aver_426_ad <- snotel_426_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_426_ad <- yearly_wy_aver_426_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_426_ad <- daily_wy_aver_426_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_426_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_426_ad <-daily_wy_aver_426_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_426_ad$date_temp_ad <- signif(daily_wy_aver2_426_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_426_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_426_ad <- daily_wy_aver_426_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_426_ad <- standard_dev_426_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_426_ad <- standard_dev_all_426_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_426_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.621773 |
| 1988 | 6.284618 |
| 1989 | 4.798125 |
| 1990 | 3.650036 |
| 1991 | 4.006171 |
| 1992 | 3.649429 |
| 1993 | 3.682784 |
| 1994 | 3.639536 |
| 1995 | 3.836511 |
| 1996 | 3.827785 |
| 1997 | 3.903998 |
| 1998 | 3.465023 |
| 1999 | 3.892704 |
| 2000 | 3.618004 |
| 2001 | 3.562946 |
| 2002 | 3.817706 |
| 2003 | 3.637774 |
| 2004 | 3.833913 |
| 2005 | 3.503265 |
| 2006 | 4.089298 |
| 2007 | 4.009181 |
| 2008 | 3.906172 |
| 2010 | 3.883319 |
| 2011 | 3.849569 |
| 2012 | 3.643763 |
| 2013 | 4.135983 |
| 2014 | 3.869632 |
| 2015 | 3.844367 |
| 2016 | 3.641130 |
| 2017 | 4.310487 |
| 2018 | 3.765110 |
| 2019 | 3.792146 |
| 2020 | 4.176947 |
| 2022 | 4.106315 |
ggplot(standard_dev_all_426_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 426 average temperatures for water years 1986-2021
sd_mk_426_ad <- mk.test(standard_dev_all_426_ad$sd_2)
print(sd_mk_426_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_426_ad$sd_2
## z = 1.0377, n = 34, p-value = 0.2994
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 71.0000000 4550.3333333 0.1265597
sd_sens_426_ad <- sens.slope(standard_dev_all_426_ad$sd_2)
print(sd_sens_426_ad)
##
## Sen's slope
##
## data: standard_dev_all_426_ad$sd_2
## z = 1.0377, n = 34, p-value = 0.2994
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.003507716 0.013980533
## sample estimates:
## Sen's slope
## 0.005075351
summer_standard_dev_all_426 <- standard_dev_426 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_426 <- summer_standard_dev_all_426 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_426 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.561915 |
| 1988 | 8.499446 |
| 1989 | 3.193889 |
| 1990 | 3.319147 |
| 1991 | 2.631014 |
| 1992 | 2.935428 |
| 1993 | 3.003495 |
| 1994 | 2.308381 |
| 1995 | 3.481043 |
| 1996 | 1.930165 |
| 1997 | 2.222906 |
| 1998 | 3.038971 |
| 1999 | 2.011450 |
| 2000 | 2.531218 |
| 2001 | 2.872546 |
| 2002 | 2.672038 |
| 2003 | 2.957826 |
| 2004 | 2.829463 |
| 2005 | 2.788555 |
| 2006 | 2.484774 |
| 2007 | 2.241179 |
| 2008 | 2.584209 |
| 2010 | 2.640244 |
| 2011 | 2.091288 |
| 2012 | 2.325230 |
| 2013 | 2.099174 |
| 2014 | 2.271605 |
| 2015 | 2.413969 |
| 2016 | 2.029779 |
| 2017 | 2.172227 |
| 2018 | 2.266581 |
| 2019 | 2.645665 |
| 2020 | 2.827783 |
| 2022 | 2.351090 |
ggplot(summer_standard_dev_all_426, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 426 average summer temperatures for water years 2005-2021
summer_sd_mk_426 <- mk.test(summer_standard_dev_all_426$sd_2)
print(summer_sd_mk_426)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_426$sd_2
## z = -2.698, n = 34, p-value = 0.006975
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -183.0000000 4550.3333333 -0.3262032
summer_sd_sens_426 <- sens.slope(summer_standard_dev_all_426$sd_2)
print(summer_sd_sens_426)
##
## Sen's slope
##
## data: summer_standard_dev_all_426$sd_2
## z = -2.698, n = 34, p-value = 0.006975
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.038983919 -0.008830423
## sample estimates:
## Sen's slope
## -0.02505147
Winter
winter_standard_dev_all_426 <- standard_dev_426 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_426 <- winter_standard_dev_all_426 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_426 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.633449 |
| 1988 | 4.588032 |
| 1989 | 5.953397 |
| 1990 | 4.345704 |
| 1991 | 5.099643 |
| 1992 | 3.788197 |
| 1993 | 4.630543 |
| 1994 | 4.681874 |
| 1995 | 4.775390 |
| 1996 | 4.735913 |
| 1997 | 4.840656 |
| 1998 | 4.188165 |
| 1999 | 4.906508 |
| 2000 | 4.310811 |
| 2001 | 4.338845 |
| 2002 | 4.711128 |
| 2003 | 4.404635 |
| 2004 | 4.619416 |
| 2005 | 4.433080 |
| 2006 | 5.090208 |
| 2007 | 4.937391 |
| 2008 | 4.626469 |
| 2010 | 4.277525 |
| 2011 | 4.834824 |
| 2012 | 4.302982 |
| 2013 | 5.134473 |
| 2014 | 4.538643 |
| 2015 | 4.753783 |
| 2016 | 4.563339 |
| 2017 | 5.223504 |
| 2018 | 4.534610 |
| 2019 | 4.308536 |
| 2020 | 4.077340 |
| 2022 | 5.084344 |
ggplot(winter_standard_dev_all_426, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 426 average winter temperatures for water years 2005-2021
winter_sd_mk_426 <- mk.test(winter_standard_dev_all_426$sd_2)
print(winter_sd_mk_426)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_426$sd_2
## z = -0.23719, n = 34, p-value = 0.8125
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -17.00000000 4550.33333333 -0.03030303
winter_sd_sens_426 <- sens.slope(winter_standard_dev_all_426$sd_2)
print(winter_sd_sens_426)
##
## Sen's slope
##
## data: winter_standard_dev_all_426$sd_2
## z = -0.23719, n = 34, p-value = 0.8125
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.0143643 0.0151971
## sample estimates:
## Sen's slope
## -0.0006290057
Summer
summer_standard_dev_all_426_ad <- standard_dev_426_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_426_ad <- summer_standard_dev_all_426_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_426_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.304273 |
| 1988 | 7.749827 |
| 1989 | 2.857093 |
| 1990 | 2.981119 |
| 1991 | 2.361494 |
| 1992 | 2.629096 |
| 1993 | 2.694918 |
| 1994 | 2.073101 |
| 1995 | 3.128469 |
| 1996 | 1.728109 |
| 1997 | 2.001086 |
| 1998 | 2.714173 |
| 1999 | 1.796497 |
| 2000 | 2.278366 |
| 2001 | 2.586670 |
| 2002 | 2.395018 |
| 2003 | 2.626229 |
| 2004 | 2.542632 |
| 2005 | 2.542724 |
| 2006 | 2.462350 |
| 2007 | 2.265665 |
| 2008 | 2.605594 |
| 2010 | 2.630546 |
| 2011 | 2.078277 |
| 2012 | 2.306938 |
| 2013 | 2.078865 |
| 2014 | 2.264114 |
| 2015 | 2.385749 |
| 2016 | 2.019871 |
| 2017 | 2.152222 |
| 2018 | 2.260432 |
| 2019 | 2.654388 |
| 2020 | 2.818208 |
| 2022 | 2.332766 |
ggplot(summer_standard_dev_all_426_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 426 average summer temperatures for water years 1986-2021
summer_sd_mk_426_ad <- mk.test(summer_standard_dev_all_426_ad$sd_2)
print(summer_sd_mk_426_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_426_ad$sd_2
## z = -1.4528, n = 34, p-value = 0.1463
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -99.0000000 4550.3333333 -0.1764706
summer_sd_sens_426_ad <- sens.slope(summer_standard_dev_all_426_ad$sd_2)
print(summer_sd_sens_426_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_426_ad$sd_2
## z = -1.4528, n = 34, p-value = 0.1463
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02470744 0.00301763
## sample estimates:
## Sen's slope
## -0.01106122
Winter
winter_standard_dev_all_426_ad <- standard_dev_426_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_426_ad <- winter_standard_dev_all_426_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_426_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.483793 |
| 1988 | 4.439307 |
| 1989 | 5.766238 |
| 1990 | 4.174383 |
| 1991 | 4.999735 |
| 1992 | 3.658075 |
| 1993 | 4.496106 |
| 1994 | 4.523864 |
| 1995 | 4.575988 |
| 1996 | 4.540164 |
| 1997 | 4.634909 |
| 1998 | 4.020920 |
| 1999 | 4.705789 |
| 2000 | 4.099080 |
| 2001 | 4.201343 |
| 2002 | 4.515914 |
| 2003 | 4.224457 |
| 2004 | 4.407266 |
| 2005 | 4.278418 |
| 2006 | 5.082393 |
| 2007 | 4.949550 |
| 2008 | 4.638489 |
| 2010 | 4.279362 |
| 2011 | 4.830591 |
| 2012 | 4.305814 |
| 2013 | 5.132933 |
| 2014 | 4.530534 |
| 2015 | 4.751074 |
| 2016 | 4.556741 |
| 2017 | 5.241161 |
| 2018 | 4.524075 |
| 2019 | 4.290539 |
| 2020 | 4.079926 |
| 2022 | 5.080857 |
ggplot(winter_standard_dev_all_426_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 426 average winter temperatures for water years 1986-2021
winter_sd_mk_426_ad <- mk.test(winter_standard_dev_all_426_ad$sd_2)
print(winter_sd_mk_426_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_426_ad$sd_2
## z = 1.1563, n = 34, p-value = 0.2476
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 79.00000 4550.33333 0.14082
winter_sd_sens_426_ad <- sens.slope(winter_standard_dev_all_426_ad$sd_2)
print(winter_sd_sens_426_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_426_ad$sd_2
## z = 1.1563, n = 34, p-value = 0.2476
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.008076346 0.021657462
## sample estimates:
## Sen's slope
## 0.006342779
spring_standard_dev_all_426 <- standard_dev_426 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_426 <- spring_standard_dev_all_426 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_426 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.837405 |
| 1988 | 4.288258 |
| 1989 | 4.654485 |
| 1990 | 3.561537 |
| 1991 | 4.304889 |
| 1992 | 3.588578 |
| 1993 | 3.164816 |
| 1994 | 3.522606 |
| 1995 | 3.125270 |
| 1996 | 4.151544 |
| 1997 | 4.227277 |
| 1998 | 3.192372 |
| 1999 | 4.073256 |
| 2000 | 4.488816 |
| 2001 | 3.615185 |
| 2002 | 3.529639 |
| 2003 | 4.314043 |
| 2004 | 3.931816 |
| 2005 | 3.409760 |
| 2006 | 3.327158 |
| 2007 | 3.723713 |
| 2008 | 3.842827 |
| 2010 | 3.776037 |
| 2011 | 3.587523 |
| 2012 | 3.811585 |
| 2013 | 4.016637 |
| 2014 | 4.369561 |
| 2015 | 3.236788 |
| 2016 | 3.274070 |
| 2017 | 4.087448 |
| 2018 | 3.291429 |
| 2019 | 3.667254 |
| 2020 | 3.834066 |
| 2022 | 4.327015 |
ggplot(spring_standard_dev_all_426, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 426 average spring temperatures for water years 2005-2021
spring_sd_mk_426 <- mk.test(spring_standard_dev_all_426$sd_2)
print(spring_sd_mk_426)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_426$sd_2
## z = -0.26684, n = 34, p-value = 0.7896
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -19.00000000 4550.33333333 -0.03386809
spring_sd_sens_426 <- sens.slope(spring_standard_dev_all_426$sd_2)
print(spring_sd_sens_426)
##
## Sen's slope
##
## data: spring_standard_dev_all_426$sd_2
## z = -0.26684, n = 34, p-value = 0.7896
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02100139 0.01296933
## sample estimates:
## Sen's slope
## -0.004355336
Fall
fall_standard_dev_all_426 <- standard_dev_426 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_426 <- fall_standard_dev_all_426 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_426 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.884732 |
| 1988 | 6.745804 |
| 1989 | 5.096664 |
| 1990 | 3.775418 |
| 1991 | 3.524701 |
| 1992 | 4.680895 |
| 1993 | 3.530917 |
| 1994 | 3.064101 |
| 1995 | 3.208967 |
| 1996 | 4.362177 |
| 1997 | 4.275355 |
| 1998 | 3.827847 |
| 1999 | 3.256104 |
| 2000 | 3.654246 |
| 2001 | 3.162884 |
| 2002 | 3.633691 |
| 2003 | 3.229079 |
| 2004 | 4.099131 |
| 2005 | 2.748810 |
| 2006 | 3.662911 |
| 2007 | 3.392219 |
| 2008 | 3.266605 |
| 2010 | 4.221162 |
| 2011 | 2.959640 |
| 2012 | 3.068566 |
| 2013 | 3.345301 |
| 2014 | 3.454693 |
| 2015 | 3.147744 |
| 2016 | 2.862284 |
| 2017 | 4.092287 |
| 2018 | 3.839550 |
| 2019 | 3.731957 |
| 2020 | 5.555161 |
| 2022 | 2.845616 |
ggplot(fall_standard_dev_all_426, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 426 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_426 <- mk.test(fall_standard_dev_all_426$sd_2)
print(fall_sd_mk_426)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_426$sd_2
## z = -1.3046, n = 34, p-value = 0.192
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -89.0000000 4550.3333333 -0.1586453
fall_sd_sens_426 <- sens.slope(fall_standard_dev_all_426$sd_2)
print(fall_sd_sens_426)
##
## Sen's slope
##
## data: fall_standard_dev_all_426$sd_2
## z = -1.3046, n = 34, p-value = 0.192
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.04464689 0.00921403
## sample estimates:
## Sen's slope
## -0.01762082
Spring
spring_standard_dev_all_426_ad <- standard_dev_426_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_426_ad <- spring_standard_dev_all_426_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_426_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.532429 |
| 1988 | 3.957866 |
| 1989 | 4.264430 |
| 1990 | 3.300775 |
| 1991 | 3.979192 |
| 1992 | 3.301636 |
| 1993 | 2.893470 |
| 1994 | 3.198425 |
| 1995 | 2.910820 |
| 1996 | 3.810213 |
| 1997 | 3.919848 |
| 1998 | 2.887783 |
| 1999 | 3.757543 |
| 2000 | 4.091753 |
| 2001 | 3.302349 |
| 2002 | 3.225349 |
| 2003 | 3.921561 |
| 2004 | 3.595824 |
| 2005 | 3.112766 |
| 2006 | 3.317861 |
| 2007 | 3.716677 |
| 2008 | 3.880227 |
| 2010 | 3.784323 |
| 2011 | 3.575653 |
| 2012 | 3.773875 |
| 2013 | 4.046846 |
| 2014 | 4.375575 |
| 2015 | 3.174395 |
| 2016 | 3.247170 |
| 2017 | 4.061459 |
| 2018 | 3.317316 |
| 2019 | 3.608775 |
| 2020 | 3.846988 |
| 2022 | 4.320131 |
ggplot(spring_standard_dev_all_426_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 426 average spring temperatures for water years 1986-2021
spring_sd_mk_426_ad <- mk.test(spring_standard_dev_all_426_ad$sd_2)
print(spring_sd_mk_426_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_426_ad$sd_2
## z = 1.097, n = 34, p-value = 0.2726
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 75.0000000 4550.3333333 0.1336898
spring_sd_sens_426_ad <- sens.slope(spring_standard_dev_all_426_ad$sd_2)
print(spring_sd_sens_426_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_426_ad$sd_2
## z = 1.097, n = 34, p-value = 0.2726
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.007517419 0.025435829
## sample estimates:
## Sen's slope
## 0.0086748
Fall
fall_standard_dev_all_426_ad <- standard_dev_426_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_426_ad <- fall_standard_dev_all_426_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_426_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.639893 |
| 1988 | 6.314365 |
| 1989 | 4.662097 |
| 1990 | 3.411545 |
| 1991 | 3.240440 |
| 1992 | 4.323651 |
| 1993 | 3.260763 |
| 1994 | 2.760201 |
| 1995 | 2.908277 |
| 1996 | 4.008820 |
| 1997 | 3.913482 |
| 1998 | 3.465670 |
| 1999 | 3.014203 |
| 2000 | 3.341717 |
| 2001 | 2.849709 |
| 2002 | 3.333744 |
| 2003 | 2.931703 |
| 2004 | 3.786224 |
| 2005 | 2.520289 |
| 2006 | 3.612694 |
| 2007 | 3.443398 |
| 2008 | 3.217693 |
| 2010 | 4.263348 |
| 2011 | 2.950439 |
| 2012 | 3.086710 |
| 2013 | 3.352698 |
| 2014 | 3.483170 |
| 2015 | 3.099394 |
| 2016 | 2.831106 |
| 2017 | 4.047741 |
| 2018 | 3.866223 |
| 2019 | 3.776151 |
| 2020 | 5.617925 |
| 2022 | 2.875449 |
ggplot(fall_standard_dev_all_426_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 426 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_426_ad <- mk.test(fall_standard_dev_all_426_ad$sd_2)
print(fall_sd_mk_426_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_426_ad$sd_2
## z = -0.029649, n = 34, p-value = 0.9763
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -3.000000e+00 4.550333e+03 -5.347594e-03
fall_sd_sens_426_ad <- sens.slope(fall_standard_dev_all_426_ad$sd_2)
print(fall_sd_sens_426_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_426_ad$sd_2
## z = -0.029649, n = 34, p-value = 0.9763
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02782460 0.02261001
## sample estimates:
## Sen's slope
## -0.001313105
Oyler -> Morrisey 7/30/2003
snotel_457 <- SNOTEL_yampa_area %>%
filter(site_id == "457")
#str(snotel_457) # check the date, usually a character.
snotel_457$Date <- as.Date(snotel_457$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_457_clean <- snotel_457 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_457_clean <- snotel_457_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_457_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_457_clean <- snotel_457_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40) %>%
filter(temperature_mean < 40)
ggplot(snotel_457_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_457_cull_count <- snotel_457_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_457_cull_count
# filtering for too few observations in a year
snotel_457_cull_count_days <- snotel_457_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_457_cull_count_days
## # A tibble: 6 x 2
## # Groups: waterYear [6]
## waterYear n
## <dbl> <int>
## 1 1985 1
## 2 1994 332
## 3 1996 349
## 4 1997 329
## 5 2003 346
## 6 2021 346
snotel_457_clean_culled <- snotel_457_clean %>%
filter(waterYear != "1985" & waterYear != "1986" & waterYear != "1994" & waterYear != "1996" & waterYear != "1997" & waterYear != "2003" & waterYear != "2021")# & waterYear != "1987" & waterYear != "1994" & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_457_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Also 1986
ggplot(snotel_457_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_457_xts <- xts(snotel_457_clean_culled$temperature_mean, order.by = snotel_457_clean_culled$Date)
dygraph(temp_457_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_457_clean_culled <- snotel_457_clean_culled %>%
# filter(temperature_mean > -30)
#temp_457_xts <- xts(snotel_457_clean_culled$temperature_mean, order.by = snotel_457_clean_culled$Date)
#dygraph(temp_457_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
snotel_457_adjusted <- snotel_457_clean_culled %>%
mutate(temp_ad = if_else(Date < "2003-07-30", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_457 <- snotel_457_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_457 <- yearly_wy_aver_457 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(temperature_mean))
#average mean temperature by day for the period of record:
daily_wy_aver_457 <- daily_wy_aver_457 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_457$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_457 <-daily_wy_aver_457 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_457$date_temp <- signif(daily_wy_aver2_457$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_457, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_457 <- daily_wy_aver_457 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_457 <- standard_dev_457 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_457 <- standard_dev_all_457 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_457 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.884974 |
| 1988 | 4.014791 |
| 1989 | 4.324895 |
| 1990 | 3.800111 |
| 1991 | 4.038363 |
| 1992 | 3.821326 |
| 1993 | 5.722207 |
| 1995 | 3.778895 |
| 1998 | 3.555486 |
| 1999 | 3.819029 |
| 2000 | 3.591974 |
| 2001 | 3.729893 |
| 2002 | 3.884897 |
| 2004 | 3.709982 |
| 2005 | 3.472614 |
| 2006 | 3.707982 |
| 2007 | 3.751542 |
| 2008 | 3.519945 |
| 2009 | 3.665004 |
| 2010 | 3.648463 |
| 2011 | 3.766168 |
| 2012 | 3.370437 |
| 2013 | 3.973797 |
| 2014 | 3.519003 |
| 2015 | 3.799974 |
| 2016 | 3.312714 |
| 2017 | 4.001117 |
| 2018 | 3.383327 |
| 2019 | 3.471526 |
| 2020 | 4.040049 |
| 2022 | 3.803178 |
ggplot(standard_dev_all_457, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 457 average temperatures for water years 2005-2021
sd_mk_457 <- mk.test(standard_dev_all_457$sd_2)
print(sd_mk_457)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_457$sd_2
## z = -2.3455, n = 31, p-value = 0.019
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -139.0000000 3461.6666667 -0.2989247
sd_sens_457 <- sens.slope(standard_dev_all_457$sd_2)
print(sd_sens_457)
##
## Sen's slope
##
## data: standard_dev_all_457$sd_2
## z = -2.3455, n = 31, p-value = 0.019
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.021914907 -0.001270345
## sample estimates:
## Sen's slope
## -0.01272964
#using the clean culled df:
#average water year temperature
yearly_wy_aver_457_ad <- snotel_457_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_457_ad <- yearly_wy_aver_457_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_457_ad <- daily_wy_aver_457_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_457_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_457_ad <-daily_wy_aver_457_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_457_ad$date_temp_ad <- signif(daily_wy_aver2_457_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_457_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_457_ad <- daily_wy_aver_457_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_457_ad <- standard_dev_457_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_457_ad <- standard_dev_all_457_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_457_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.645348 |
| 1988 | 3.665185 |
| 1989 | 4.055607 |
| 1990 | 3.513014 |
| 1991 | 3.810883 |
| 1992 | 3.622286 |
| 1993 | 5.419071 |
| 1995 | 3.589615 |
| 1998 | 3.299813 |
| 1999 | 3.655912 |
| 2000 | 3.355427 |
| 2001 | 3.415352 |
| 2002 | 3.542588 |
| 2004 | 3.656210 |
| 2005 | 3.423205 |
| 2006 | 3.717944 |
| 2007 | 3.782830 |
| 2008 | 3.548199 |
| 2009 | 3.611844 |
| 2010 | 3.649976 |
| 2011 | 3.761584 |
| 2012 | 3.393902 |
| 2013 | 4.006266 |
| 2014 | 3.500715 |
| 2015 | 3.734459 |
| 2016 | 3.316833 |
| 2017 | 3.963337 |
| 2018 | 3.367592 |
| 2019 | 3.483300 |
| 2020 | 4.062368 |
| 2022 | 3.788996 |
ggplot(standard_dev_all_457_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 457 average temperatures for water years 1986-2021
sd_mk_457_ad <- mk.test(standard_dev_all_457_ad$sd_2)
print(sd_mk_457_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_457_ad$sd_2
## z = 0.067986, n = 31, p-value = 0.9458
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 5.000000e+00 3.461667e+03 1.075269e-02
sd_sens_457_ad <- sens.slope(standard_dev_all_457_ad$sd_2)
print(sd_sens_457_ad)
##
## Sen's slope
##
## data: standard_dev_all_457_ad$sd_2
## z = 0.067986, n = 31, p-value = 0.9458
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.009521827 0.010854648
## sample estimates:
## Sen's slope
## 0.0002504338
summer_standard_dev_all_457 <- standard_dev_457 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_457 <- summer_standard_dev_all_457 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_457 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.715034 |
| 1988 | 2.556229 |
| 1989 | 2.993638 |
| 1990 | 3.686055 |
| 1991 | 2.675449 |
| 1992 | 2.972210 |
| 1993 | 3.821814 |
| 1995 | 3.172156 |
| 1998 | 3.114769 |
| 1999 | 1.879389 |
| 2000 | 2.581509 |
| 2001 | 2.869486 |
| 2002 | 2.674083 |
| 2004 | 2.636336 |
| 2005 | 2.843564 |
| 2006 | 2.458939 |
| 2007 | 2.268531 |
| 2008 | 2.618322 |
| 2009 | 2.248735 |
| 2010 | 2.226268 |
| 2011 | 2.050133 |
| 2012 | 2.231663 |
| 2013 | 2.089620 |
| 2014 | 2.342618 |
| 2015 | 2.438775 |
| 2016 | 2.188310 |
| 2017 | 2.048909 |
| 2018 | 2.267535 |
| 2019 | 2.459158 |
| 2020 | 2.778913 |
| 2022 | 2.356948 |
ggplot(summer_standard_dev_all_457, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 457 average summer temperatures for water years 2005-2021
summer_sd_mk_457 <- mk.test(summer_standard_dev_all_457$sd_2)
print(summer_sd_mk_457)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_457$sd_2
## z = -3.3993, n = 31, p-value = 0.0006756
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -201.0000000 3461.6666667 -0.4322581
summer_sd_sens_457 <- sens.slope(summer_standard_dev_all_457$sd_2)
print(summer_sd_sens_457)
##
## Sen's slope
##
## data: summer_standard_dev_all_457$sd_2
## z = -3.3993, n = 31, p-value = 0.0006756
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.04396671 -0.01225003
## sample estimates:
## Sen's slope
## -0.02663665
Winter
winter_standard_dev_all_457 <- standard_dev_457 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_457 <- winter_standard_dev_all_457 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_457 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.388486 |
| 1988 | 4.308822 |
| 1989 | 5.245875 |
| 1990 | 3.929205 |
| 1991 | 4.800144 |
| 1992 | 3.879404 |
| 1993 | 4.066957 |
| 1995 | 4.417012 |
| 1998 | 3.983577 |
| 1999 | 4.481958 |
| 2000 | 3.757025 |
| 2001 | 4.045222 |
| 2002 | 4.314290 |
| 2004 | 4.045809 |
| 2005 | 4.060581 |
| 2006 | 4.433084 |
| 2007 | 4.570095 |
| 2008 | 3.975320 |
| 2009 | 4.290873 |
| 2010 | 4.067131 |
| 2011 | 4.690569 |
| 2012 | 3.919100 |
| 2013 | 4.790811 |
| 2014 | 3.885731 |
| 2015 | 4.599394 |
| 2016 | 3.952992 |
| 2017 | 4.710055 |
| 2018 | 3.922943 |
| 2019 | 4.013772 |
| 2020 | 3.757616 |
| 2022 | 4.510978 |
ggplot(winter_standard_dev_all_457, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 457 average winter temperatures for water years 2005-2021
winter_sd_mk_457 <- mk.test(winter_standard_dev_all_457$sd_2)
print(winter_sd_mk_457)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_457$sd_2
## z = -0.50989, n = 31, p-value = 0.6101
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -31.00000000 3461.66666667 -0.06666667
winter_sd_sens_457 <- sens.slope(winter_standard_dev_all_457$sd_2)
print(winter_sd_sens_457)
##
## Sen's slope
##
## data: winter_standard_dev_all_457$sd_2
## z = -0.50989, n = 31, p-value = 0.6101
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01920191 0.01092712
## sample estimates:
## Sen's slope
## -0.003902823
Summer
summer_standard_dev_all_457_ad <- standard_dev_457_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_457_ad <- summer_standard_dev_all_457_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_457_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.440975 |
| 1988 | 2.317422 |
| 1989 | 2.661004 |
| 1990 | 3.320028 |
| 1991 | 2.414911 |
| 1992 | 2.671853 |
| 1993 | 3.454838 |
| 1995 | 2.847482 |
| 1998 | 2.761645 |
| 1999 | 1.677913 |
| 2000 | 2.322446 |
| 2001 | 2.579485 |
| 2002 | 2.400801 |
| 2004 | 2.620217 |
| 2005 | 2.881576 |
| 2006 | 2.437167 |
| 2007 | 2.293169 |
| 2008 | 2.639301 |
| 2009 | 2.255995 |
| 2010 | 2.217062 |
| 2011 | 2.051982 |
| 2012 | 2.212844 |
| 2013 | 2.068541 |
| 2014 | 2.338613 |
| 2015 | 2.407117 |
| 2016 | 2.157603 |
| 2017 | 2.027620 |
| 2018 | 2.255235 |
| 2019 | 2.471745 |
| 2020 | 2.764237 |
| 2022 | 2.343038 |
ggplot(summer_standard_dev_all_457_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 457 average summer temperatures for water years 1986-2021
summer_sd_mk_457_ad <- mk.test(summer_standard_dev_all_457_ad$sd_2)
print(summer_sd_mk_457_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_457_ad$sd_2
## z = -2.2775, n = 31, p-value = 0.02276
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -135.0000000 3461.6666667 -0.2903226
summer_sd_sens_457_ad <- sens.slope(summer_standard_dev_all_457_ad$sd_2)
print(summer_sd_sens_457_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_457_ad$sd_2
## z = -2.2775, n = 31, p-value = 0.02276
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.027046391 -0.002712733
## sample estimates:
## Sen's slope
## -0.01381021
Winter
winter_standard_dev_all_457_ad <- standard_dev_457_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_457_ad <- winter_standard_dev_all_457_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_457_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.228054 |
| 1988 | 4.141521 |
| 1989 | 5.089489 |
| 1990 | 3.759066 |
| 1991 | 4.696255 |
| 1992 | 3.733794 |
| 1993 | 3.909935 |
| 1995 | 4.233399 |
| 1998 | 3.838113 |
| 1999 | 4.324385 |
| 2000 | 3.575518 |
| 2001 | 3.916584 |
| 2002 | 4.144328 |
| 2004 | 4.050383 |
| 2005 | 4.044804 |
| 2006 | 4.432058 |
| 2007 | 4.579749 |
| 2008 | 3.984739 |
| 2009 | 4.282469 |
| 2010 | 4.069145 |
| 2011 | 4.686978 |
| 2012 | 3.914672 |
| 2013 | 4.789729 |
| 2014 | 3.881118 |
| 2015 | 4.593943 |
| 2016 | 3.945343 |
| 2017 | 4.722885 |
| 2018 | 3.911439 |
| 2019 | 4.002148 |
| 2020 | 3.754267 |
| 2022 | 4.507667 |
ggplot(winter_standard_dev_all_457_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 457 average winter temperatures for water years 1986-2021
winter_sd_mk_457_ad <- mk.test(winter_standard_dev_all_457_ad$sd_2)
print(winter_sd_mk_457_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_457_ad$sd_2
## z = 0.30594, n = 31, p-value = 0.7597
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 1.900000e+01 3.461667e+03 4.086022e-02
winter_sd_sens_457_ad <- sens.slope(winter_standard_dev_all_457_ad$sd_2)
print(winter_sd_sens_457_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_457_ad$sd_2
## z = 0.30594, n = 31, p-value = 0.7597
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01437935 0.02006409
## sample estimates:
## Sen's slope
## 0.001863624
spring_standard_dev_all_457 <- standard_dev_457 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_457 <- spring_standard_dev_all_457 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_457 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.386031 |
| 1988 | 4.459451 |
| 1989 | 3.822866 |
| 1990 | 3.299009 |
| 1991 | 4.009404 |
| 1992 | 3.411259 |
| 1993 | 3.046514 |
| 1995 | 2.670175 |
| 1998 | 2.841989 |
| 1999 | 4.227073 |
| 2000 | 4.087119 |
| 2001 | 3.318495 |
| 2002 | 3.298014 |
| 2004 | 3.638133 |
| 2005 | 3.183624 |
| 2006 | 3.143637 |
| 2007 | 3.588017 |
| 2008 | 3.440174 |
| 2009 | 3.243501 |
| 2010 | 3.847503 |
| 2011 | 3.265820 |
| 2012 | 3.617653 |
| 2013 | 4.133515 |
| 2014 | 3.824506 |
| 2015 | 3.048643 |
| 2016 | 3.003636 |
| 2017 | 4.042746 |
| 2018 | 3.129144 |
| 2019 | 3.355311 |
| 2020 | 3.890975 |
| 2022 | 3.991301 |
ggplot(spring_standard_dev_all_457, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 457 average spring temperatures for water years 2005-2021
spring_sd_mk_457 <- mk.test(spring_standard_dev_all_457$sd_2)
print(spring_sd_mk_457)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_457$sd_2
## z = -0.44191, n = 31, p-value = 0.6586
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -27.00000000 3461.66666667 -0.05806452
spring_sd_sens_457 <- sens.slope(spring_standard_dev_all_457$sd_2)
print(spring_sd_sens_457)
##
## Sen's slope
##
## data: spring_standard_dev_all_457$sd_2
## z = -0.44191, n = 31, p-value = 0.6586
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02441413 0.02027985
## sample estimates:
## Sen's slope
## -0.005749092
Fall
fall_standard_dev_all_457 <- standard_dev_457 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_457 <- fall_standard_dev_all_457 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_457 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.258978 |
| 1988 | 3.335103 |
| 1989 | 3.043591 |
| 1990 | 3.937161 |
| 1991 | 3.601756 |
| 1992 | 4.285951 |
| 1993 | 10.491729 |
| 1995 | 3.297522 |
| 1998 | 3.565366 |
| 1999 | 3.419214 |
| 2000 | 3.873739 |
| 2001 | 3.250979 |
| 2002 | 3.286525 |
| 2004 | 3.705007 |
| 2005 | 2.337545 |
| 2006 | 3.556737 |
| 2007 | 3.230608 |
| 2008 | 3.363509 |
| 2009 | 3.376364 |
| 2010 | 4.016771 |
| 2011 | 2.997267 |
| 2012 | 2.868907 |
| 2013 | 3.563170 |
| 2014 | 3.642415 |
| 2015 | 3.141705 |
| 2016 | 2.818319 |
| 2017 | 3.782320 |
| 2018 | 3.503160 |
| 2019 | 3.384743 |
| 2020 | 5.610141 |
| 2022 | 3.205941 |
ggplot(fall_standard_dev_all_457, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 457 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_457 <- mk.test(fall_standard_dev_all_457$sd_2)
print(fall_sd_mk_457)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_457$sd_2
## z = -0.61187, n = 31, p-value = 0.5406
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -37.00000000 3461.66666667 -0.07956989
fall_sd_sens_457 <- sens.slope(fall_standard_dev_all_457$sd_2)
print(fall_sd_sens_457)
##
## Sen's slope
##
## data: fall_standard_dev_all_457$sd_2
## z = -0.61187, n = 31, p-value = 0.5406
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02398242 0.01396515
## sample estimates:
## Sen's slope
## -0.004464742
Spring
spring_standard_dev_all_457_ad <- standard_dev_457_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_457_ad <- spring_standard_dev_all_457_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_457_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.010234 |
| 1988 | 4.063885 |
| 1989 | 3.477151 |
| 1990 | 3.040868 |
| 1991 | 3.641795 |
| 1992 | 3.134867 |
| 1993 | 2.752124 |
| 1995 | 2.493756 |
| 1998 | 2.559476 |
| 1999 | 3.886270 |
| 2000 | 3.725227 |
| 2001 | 3.027271 |
| 2002 | 2.999060 |
| 2004 | 3.609415 |
| 2005 | 3.189020 |
| 2006 | 3.137605 |
| 2007 | 3.590867 |
| 2008 | 3.469474 |
| 2009 | 3.270375 |
| 2010 | 3.848606 |
| 2011 | 3.245933 |
| 2012 | 3.590219 |
| 2013 | 4.163119 |
| 2014 | 3.836515 |
| 2015 | 3.008115 |
| 2016 | 2.986892 |
| 2017 | 4.020390 |
| 2018 | 3.164311 |
| 2019 | 3.309858 |
| 2020 | 3.913199 |
| 2022 | 3.982235 |
ggplot(spring_standard_dev_all_457_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 457 average spring temperatures for water years 1986-2021
spring_sd_mk_457_ad <- mk.test(spring_standard_dev_all_457_ad$sd_2)
print(spring_sd_mk_457_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_457_ad$sd_2
## z = 0.88381, n = 31, p-value = 0.3768
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 53.0000000 3461.6666667 0.1139785
spring_sd_sens_457_ad <- sens.slope(spring_standard_dev_all_457_ad$sd_2)
print(spring_sd_sens_457_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_457_ad$sd_2
## z = 0.88381, n = 31, p-value = 0.3768
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01178487 0.03389473
## sample estimates:
## Sen's slope
## 0.01042372
Fall
fall_standard_dev_all_457_ad <- standard_dev_457_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_457_ad <- fall_standard_dev_all_457_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_457_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.989854 |
| 1988 | 3.047028 |
| 1989 | 2.809749 |
| 1990 | 3.500073 |
| 1991 | 3.282132 |
| 1992 | 3.956609 |
| 1993 | 9.897354 |
| 1995 | 2.962855 |
| 1998 | 3.147154 |
| 1999 | 3.196750 |
| 2000 | 3.546844 |
| 2001 | 2.928983 |
| 2002 | 3.006940 |
| 2004 | 3.661237 |
| 2005 | 2.354633 |
| 2006 | 3.516974 |
| 2007 | 3.273133 |
| 2008 | 3.330535 |
| 2009 | 3.386184 |
| 2010 | 4.041544 |
| 2011 | 3.000260 |
| 2012 | 2.907570 |
| 2013 | 3.591512 |
| 2014 | 3.673234 |
| 2015 | 3.108161 |
| 2016 | 2.786871 |
| 2017 | 3.757872 |
| 2018 | 3.527010 |
| 2019 | 3.427057 |
| 2020 | 5.666724 |
| 2022 | 3.232635 |
ggplot(fall_standard_dev_all_457_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 457 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_457_ad <- mk.test(fall_standard_dev_all_457_ad$sd_2)
print(fall_sd_mk_457_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_457_ad$sd_2
## z = 1.1897, n = 31, p-value = 0.2341
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 71.0000000 3461.6666667 0.1526882
fall_sd_sens_457_ad <- sens.slope(fall_standard_dev_all_457_ad$sd_2)
print(fall_sd_sens_457_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_457_ad$sd_2
## z = 1.1897, n = 31, p-value = 0.2341
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.007747232 0.029712171
## sample estimates:
## Sen's slope
## 0.01172958
Oyler -> Morrisey 8/7/2006
snotel_467 <- SNOTEL_yampa_area %>%
filter(site_id == "467")
#str(snotel_467) # check the date, usually a character.
snotel_467$Date <- as.Date(snotel_467$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_467_clean <- snotel_467 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_467_clean <- snotel_467_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_467_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_467_clean <- snotel_467_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40) %>%
filter(temperature_mean < 40)
ggplot(snotel_467_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_467_cull_count <- snotel_467_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_467_cull_count
# filtering for too few observations in a year
snotel_467_cull_count_days <- snotel_467_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_467_cull_count_days
## # A tibble: 6 x 2
## # Groups: waterYear [6]
## waterYear n
## <dbl> <int>
## 1 1985 1
## 2 1994 326
## 3 1998 342
## 4 1999 281
## 5 2001 339
## 6 2021 344
snotel_467_clean_culled <- snotel_467_clean %>%
filter(waterYear != "1985" & waterYear != "1986" & waterYear != "1994" & waterYear != "1998" & waterYear != "1999" & waterYear != "2001" & waterYear != "2021")# & waterYear != "2021")# & waterYear != "1987" & waterYear != "1994" & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_467_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Also 1986
ggplot(snotel_467_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_467_xts <- xts(snotel_467_clean_culled$temperature_mean, order.by = snotel_467_clean_culled$Date)
dygraph(temp_467_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_467_clean_culled <- snotel_467_clean_culled %>%
# filter(temperature_mean > -30)
#temp_467_xts <- xts(snotel_467_clean_culled$temperature_mean, order.by = snotel_467_clean_culled$Date)
#dygraph(temp_467_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
snotel_467_adjusted <- snotel_467_clean_culled %>%
mutate(temp_ad = if_else(Date < "2006-08-07", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_467 <- snotel_467_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_467 <- yearly_wy_aver_467 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(temperature_mean))
#average mean temperature by day for the period of record:
daily_wy_aver_467 <- daily_wy_aver_467 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_467$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_467 <-daily_wy_aver_467 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_467$date_temp <- signif(daily_wy_aver2_467$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_467, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_467 <- daily_wy_aver_467 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_467 <- standard_dev_467 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_467 <- standard_dev_all_467 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_467 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.145999 |
| 1988 | 4.540989 |
| 1989 | 4.813588 |
| 1990 | 4.099732 |
| 1991 | 4.399539 |
| 1992 | 4.337342 |
| 1993 | 4.115276 |
| 1995 | 4.206810 |
| 1996 | 4.099000 |
| 1997 | 4.118831 |
| 2000 | 4.115022 |
| 2002 | 4.236140 |
| 2003 | 3.935416 |
| 2004 | 4.252626 |
| 2005 | 3.710645 |
| 2006 | 4.277168 |
| 2007 | 4.029093 |
| 2008 | 3.866990 |
| 2009 | 4.006806 |
| 2010 | 3.899850 |
| 2011 | 3.849996 |
| 2012 | 3.715984 |
| 2013 | 4.270444 |
| 2014 | 3.899404 |
| 2015 | 4.163138 |
| 2016 | 3.597994 |
| 2017 | 4.347721 |
| 2018 | 3.730401 |
| 2019 | 3.749406 |
| 2020 | 4.233462 |
| 2022 | 4.158564 |
ggplot(standard_dev_all_467, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 467 average temperatures for water years 2005-2021
sd_mk_467 <- mk.test(standard_dev_all_467$sd_2)
print(sd_mk_467)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_467$sd_2
## z = -2.5495, n = 31, p-value = 0.01079
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -151.0000000 3461.6666667 -0.3247312
sd_sens_467 <- sens.slope(standard_dev_all_467$sd_2)
print(sd_sens_467)
##
## Sen's slope
##
## data: standard_dev_all_467$sd_2
## z = -2.5495, n = 31, p-value = 0.01079
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02661947 -0.00432832
## sample estimates:
## Sen's slope
## -0.01539253
#using the clean culled df:
#average water year temperature
yearly_wy_aver_467_ad <- snotel_467_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_467_ad <- yearly_wy_aver_467_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_467_ad <- daily_wy_aver_467_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_467_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_467_ad <-daily_wy_aver_467_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_467_ad$date_temp_ad <- signif(daily_wy_aver2_467_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_467_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_467_ad <- daily_wy_aver_467_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_467_ad <- standard_dev_467_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_467_ad <- standard_dev_all_467_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_467_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.897877 |
| 1988 | 4.166810 |
| 1989 | 4.517446 |
| 1990 | 3.809051 |
| 1991 | 4.164976 |
| 1992 | 4.101268 |
| 1993 | 3.862819 |
| 1995 | 3.991982 |
| 1996 | 3.869998 |
| 1997 | 3.891711 |
| 2000 | 3.849542 |
| 2002 | 3.910714 |
| 2003 | 3.658870 |
| 2004 | 4.024479 |
| 2005 | 3.518339 |
| 2006 | 4.066730 |
| 2007 | 4.047461 |
| 2008 | 3.891100 |
| 2009 | 3.935836 |
| 2010 | 3.903805 |
| 2011 | 3.848928 |
| 2012 | 3.730038 |
| 2013 | 4.302517 |
| 2014 | 3.867339 |
| 2015 | 4.080572 |
| 2016 | 3.593402 |
| 2017 | 4.299547 |
| 2018 | 3.703800 |
| 2019 | 3.767250 |
| 2020 | 4.265659 |
| 2022 | 4.152731 |
ggplot(standard_dev_all_467_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 467 average temperatures for water years 1986-2021
sd_mk_467_ad <- mk.test(standard_dev_all_467_ad$sd_2)
print(sd_mk_467_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_467_ad$sd_2
## z = -0.61187, n = 31, p-value = 0.5406
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -37.00000000 3461.66666667 -0.07956989
sd_sens_467_ad <- sens.slope(standard_dev_all_467_ad$sd_2)
print(sd_sens_467_ad)
##
## Sen's slope
##
## data: standard_dev_all_467_ad$sd_2
## z = -0.61187, n = 31, p-value = 0.5406
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.013472791 0.006773726
## sample estimates:
## Sen's slope
## -0.003319246
summer_standard_dev_all_467 <- standard_dev_467 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_467 <- summer_standard_dev_all_467 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_467 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.951866 |
| 1988 | 3.122046 |
| 1989 | 3.666727 |
| 1990 | 3.496364 |
| 1991 | 2.501052 |
| 1992 | 3.228632 |
| 1993 | 3.962014 |
| 1995 | 3.474405 |
| 1996 | 2.019638 |
| 1997 | 2.426146 |
| 2000 | 2.883427 |
| 2002 | 2.872409 |
| 2003 | 3.265097 |
| 2004 | 3.042612 |
| 2005 | 3.343196 |
| 2006 | 2.912617 |
| 2007 | 2.468128 |
| 2008 | 3.026408 |
| 2009 | 2.538826 |
| 2010 | 2.436467 |
| 2011 | 2.274045 |
| 2012 | 2.404012 |
| 2013 | 2.450505 |
| 2014 | 2.598154 |
| 2015 | 2.694083 |
| 2016 | 2.326506 |
| 2017 | 2.378353 |
| 2018 | 2.494011 |
| 2019 | 2.687749 |
| 2020 | 2.839960 |
| 2022 | 2.460476 |
ggplot(summer_standard_dev_all_467, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 467 average summer temperatures for water years 2005-2021
summer_sd_mk_467 <- mk.test(summer_standard_dev_all_467$sd_2)
print(summer_sd_mk_467)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_467$sd_2
## z = -2.8894, n = 31, p-value = 0.00386
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -171.0000000 3461.6666667 -0.3677419
summer_sd_sens_467 <- sens.slope(summer_standard_dev_all_467$sd_2)
print(summer_sd_sens_467)
##
## Sen's slope
##
## data: summer_standard_dev_all_467$sd_2
## z = -2.8894, n = 31, p-value = 0.00386
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.044445765 -0.008302021
## sample estimates:
## Sen's slope
## -0.0256963
Winter
winter_standard_dev_all_467 <- standard_dev_467 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_467 <- winter_standard_dev_all_467 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_467 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.807249 |
| 1988 | 4.695919 |
| 1989 | 5.557602 |
| 1990 | 4.423012 |
| 1991 | 5.187413 |
| 1992 | 4.318765 |
| 1993 | 4.397918 |
| 1995 | 4.732098 |
| 1996 | 4.765163 |
| 1997 | 4.722889 |
| 2000 | 4.400274 |
| 2002 | 4.741924 |
| 2003 | 4.240216 |
| 2004 | 4.647977 |
| 2005 | 4.222899 |
| 2006 | 5.007043 |
| 2007 | 4.902428 |
| 2008 | 4.293852 |
| 2009 | 4.672422 |
| 2010 | 4.238347 |
| 2011 | 4.686434 |
| 2012 | 4.348109 |
| 2013 | 5.172502 |
| 2014 | 4.250876 |
| 2015 | 5.003587 |
| 2016 | 4.322953 |
| 2017 | 5.011875 |
| 2018 | 4.311699 |
| 2019 | 4.300647 |
| 2020 | 3.912165 |
| 2022 | 4.887383 |
ggplot(winter_standard_dev_all_467, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 467 average winter temperatures for water years 2005-2021
winter_sd_mk_467 <- mk.test(winter_standard_dev_all_467$sd_2)
print(winter_sd_mk_467)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_467$sd_2
## z = -1.4277, n = 31, p-value = 0.1534
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -85.0000000 3461.6666667 -0.1827957
winter_sd_sens_467 <- sens.slope(winter_standard_dev_all_467$sd_2)
print(winter_sd_sens_467)
##
## Sen's slope
##
## data: winter_standard_dev_all_467$sd_2
## z = -1.4277, n = 31, p-value = 0.1534
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.024019831 0.004144003
## sample estimates:
## Sen's slope
## -0.007746222
Summer
summer_standard_dev_all_467_ad <- standard_dev_467_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_467_ad <- summer_standard_dev_all_467_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_467_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.661099 |
| 1988 | 2.813713 |
| 1989 | 3.272530 |
| 1990 | 3.144473 |
| 1991 | 2.248762 |
| 1992 | 2.904015 |
| 1993 | 3.572050 |
| 1995 | 3.119035 |
| 1996 | 1.823712 |
| 1997 | 2.185937 |
| 2000 | 2.594429 |
| 2002 | 2.579701 |
| 2003 | 2.891295 |
| 2004 | 2.744692 |
| 2005 | 2.972598 |
| 2006 | 2.699705 |
| 2007 | 2.482490 |
| 2008 | 3.042267 |
| 2009 | 2.557233 |
| 2010 | 2.435837 |
| 2011 | 2.267432 |
| 2012 | 2.372337 |
| 2013 | 2.421113 |
| 2014 | 2.594249 |
| 2015 | 2.646408 |
| 2016 | 2.293848 |
| 2017 | 2.349915 |
| 2018 | 2.485827 |
| 2019 | 2.706459 |
| 2020 | 2.828304 |
| 2022 | 2.453579 |
ggplot(summer_standard_dev_all_467_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 467 average summer temperatures for water years 1986-2021
summer_sd_mk_467_ad <- mk.test(summer_standard_dev_all_467_ad$sd_2)
print(summer_sd_mk_467_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_467_ad$sd_2
## z = -1.8356, n = 31, p-value = 0.06641
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -109.0000000 3461.6666667 -0.2344086
summer_sd_sens_467_ad <- sens.slope(summer_standard_dev_all_467_ad$sd_2)
print(summer_sd_sens_467_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_467_ad$sd_2
## z = -1.8356, n = 31, p-value = 0.06641
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.027031212 0.001166882
## sample estimates:
## Sen's slope
## -0.01469003
Winter
winter_standard_dev_all_467_ad <- standard_dev_467_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_467_ad <- winter_standard_dev_all_467_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_467_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.630721 |
| 1988 | 4.530007 |
| 1989 | 5.390975 |
| 1990 | 4.256296 |
| 1991 | 5.080840 |
| 1992 | 4.172421 |
| 1993 | 4.248910 |
| 1995 | 4.536605 |
| 1996 | 4.583184 |
| 1997 | 4.537123 |
| 2000 | 4.164101 |
| 2002 | 4.563031 |
| 2003 | 4.075656 |
| 2004 | 4.447377 |
| 2005 | 4.074093 |
| 2006 | 4.826786 |
| 2007 | 4.911552 |
| 2008 | 4.308592 |
| 2009 | 4.662025 |
| 2010 | 4.239998 |
| 2011 | 4.685099 |
| 2012 | 4.345864 |
| 2013 | 5.170815 |
| 2014 | 4.247590 |
| 2015 | 4.993758 |
| 2016 | 4.315622 |
| 2017 | 5.031076 |
| 2018 | 4.300387 |
| 2019 | 4.284824 |
| 2020 | 3.915817 |
| 2022 | 4.882328 |
ggplot(winter_standard_dev_all_467_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 467 average winter temperatures for water years 1986-2021
winter_sd_mk_467_ad <- mk.test(winter_standard_dev_all_467_ad$sd_2)
print(winter_sd_mk_467_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_467_ad$sd_2
## z = -0.20396, n = 31, p-value = 0.8384
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -13.00000000 3461.66666667 -0.02795699
winter_sd_sens_467_ad <- sens.slope(winter_standard_dev_all_467_ad$sd_2)
print(winter_sd_sens_467_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_467_ad$sd_2
## z = -0.20396, n = 31, p-value = 0.8384
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01593830 0.01307104
## sample estimates:
## Sen's slope
## -0.001664032
spring_standard_dev_all_467 <- standard_dev_467 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_467 <- spring_standard_dev_all_467 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_467 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.326741 |
| 1988 | 4.912868 |
| 1989 | 5.008660 |
| 1990 | 3.831994 |
| 1991 | 4.690650 |
| 1992 | 4.023824 |
| 1993 | 3.367622 |
| 1995 | 2.924851 |
| 1996 | 4.099916 |
| 1997 | 4.302148 |
| 2000 | 4.674244 |
| 2002 | 3.838982 |
| 2003 | 4.583058 |
| 2004 | 4.140414 |
| 2005 | 3.741618 |
| 2006 | 3.784800 |
| 2007 | 3.960795 |
| 2008 | 3.770284 |
| 2009 | 3.510560 |
| 2010 | 4.008282 |
| 2011 | 3.404504 |
| 2012 | 4.003113 |
| 2013 | 4.528477 |
| 2014 | 4.354371 |
| 2015 | 3.294313 |
| 2016 | 3.368663 |
| 2017 | 4.330573 |
| 2018 | 3.384159 |
| 2019 | 3.616551 |
| 2020 | 4.280672 |
| 2022 | 4.387805 |
ggplot(spring_standard_dev_all_467, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 467 average spring temperatures for water years 2005-2021
spring_sd_mk_467 <- mk.test(spring_standard_dev_all_467$sd_2)
print(spring_sd_mk_467)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_467$sd_2
## z = -1.5297, n = 31, p-value = 0.1261
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -91.0000000 3461.6666667 -0.1956989
spring_sd_sens_467 <- sens.slope(spring_standard_dev_all_467$sd_2)
print(spring_sd_sens_467)
##
## Sen's slope
##
## data: spring_standard_dev_all_467$sd_2
## z = -1.5297, n = 31, p-value = 0.1261
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.040433402 0.008099548
## sample estimates:
## Sen's slope
## -0.01778742
Fall
fall_standard_dev_all_467 <- standard_dev_467 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_467 <- fall_standard_dev_all_467 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_467 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.150535 |
| 1988 | 3.777988 |
| 1989 | 3.346905 |
| 1990 | 4.172506 |
| 1991 | 4.077039 |
| 1992 | 5.030504 |
| 1993 | 4.027397 |
| 1995 | 4.384327 |
| 1996 | 4.347619 |
| 1997 | 4.343609 |
| 2000 | 4.320396 |
| 2002 | 3.913824 |
| 2003 | 2.984170 |
| 2004 | 4.434295 |
| 2005 | 2.643661 |
| 2006 | 3.818195 |
| 2007 | 3.305078 |
| 2008 | 3.890880 |
| 2009 | 3.644241 |
| 2010 | 4.583592 |
| 2011 | 3.236597 |
| 2012 | 3.182552 |
| 2013 | 3.530531 |
| 2014 | 3.978222 |
| 2015 | 3.535302 |
| 2016 | 3.168156 |
| 2017 | 4.395181 |
| 2018 | 3.929899 |
| 2019 | 3.824415 |
| 2020 | 5.970935 |
| 2022 | 3.680200 |
ggplot(fall_standard_dev_all_467, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 467 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_467 <- mk.test(fall_standard_dev_all_467$sd_2)
print(fall_sd_mk_467)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_467$sd_2
## z = -0.37392, n = 31, p-value = 0.7085
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -23.00000000 3461.66666667 -0.04946237
fall_sd_sens_467 <- sens.slope(fall_standard_dev_all_467$sd_2)
print(fall_sd_sens_467)
##
## Sen's slope
##
## data: fall_standard_dev_all_467$sd_2
## z = -0.37392, n = 31, p-value = 0.7085
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02977176 0.02406714
## sample estimates:
## Sen's slope
## -0.00612817
Spring
spring_standard_dev_all_467_ad <- standard_dev_467_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_467_ad <- spring_standard_dev_all_467_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_467_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.963305 |
| 1988 | 4.496709 |
| 1989 | 4.589202 |
| 1990 | 3.541552 |
| 1991 | 4.306041 |
| 1992 | 3.691823 |
| 1993 | 3.043919 |
| 1995 | 2.739123 |
| 1996 | 3.763468 |
| 1997 | 3.985882 |
| 2000 | 4.262281 |
| 2002 | 3.500632 |
| 2003 | 4.174684 |
| 2004 | 3.804169 |
| 2005 | 3.427167 |
| 2006 | 3.448435 |
| 2007 | 3.952989 |
| 2008 | 3.804973 |
| 2009 | 3.535751 |
| 2010 | 4.006228 |
| 2011 | 3.390196 |
| 2012 | 3.968383 |
| 2013 | 4.563844 |
| 2014 | 4.366818 |
| 2015 | 3.234748 |
| 2016 | 3.352451 |
| 2017 | 4.307196 |
| 2018 | 3.408838 |
| 2019 | 3.567042 |
| 2020 | 4.291095 |
| 2022 | 4.375108 |
ggplot(spring_standard_dev_all_467_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 467 average spring temperatures for water years 1986-2021
spring_sd_mk_467_ad <- mk.test(spring_standard_dev_all_467_ad$sd_2)
print(spring_sd_mk_467_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_467_ad$sd_2
## z = -0.033993, n = 31, p-value = 0.9729
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -3.000000e+00 3.461667e+03 -6.451613e-03
spring_sd_sens_467_ad <- sens.slope(spring_standard_dev_all_467_ad$sd_2)
print(spring_sd_sens_467_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_467_ad$sd_2
## z = -0.033993, n = 31, p-value = 0.9729
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02292232 0.02388160
## sample estimates:
## Sen's slope
## -0.000597849
Fall
fall_standard_dev_all_467_ad <- standard_dev_467_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_467_ad <- fall_standard_dev_all_467_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_467_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.888808 |
| 1988 | 3.469428 |
| 1989 | 3.123380 |
| 1990 | 3.756769 |
| 1991 | 3.746942 |
| 1992 | 4.658871 |
| 1993 | 3.737681 |
| 1995 | 4.011672 |
| 1996 | 4.005513 |
| 1997 | 3.968226 |
| 2000 | 3.969460 |
| 2002 | 3.600482 |
| 2003 | 2.717745 |
| 2004 | 4.104857 |
| 2005 | 2.384230 |
| 2006 | 3.820552 |
| 2007 | 3.343170 |
| 2008 | 3.819057 |
| 2009 | 3.637540 |
| 2010 | 4.626378 |
| 2011 | 3.220716 |
| 2012 | 3.197842 |
| 2013 | 3.562917 |
| 2014 | 3.993028 |
| 2015 | 3.483963 |
| 2016 | 3.114236 |
| 2017 | 4.358122 |
| 2018 | 3.957780 |
| 2019 | 3.859870 |
| 2020 | 6.044747 |
| 2022 | 3.716374 |
ggplot(fall_standard_dev_all_467_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 467 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_467_ad <- mk.test(fall_standard_dev_all_467_ad$sd_2)
print(fall_sd_mk_467_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_467_ad$sd_2
## z = 0.61187, n = 31, p-value = 0.5406
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 3.700000e+01 3.461667e+03 7.956989e-02
fall_sd_sens_467_ad <- sens.slope(fall_standard_dev_all_467_ad$sd_2)
print(fall_sd_sens_467_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_467_ad$sd_2
## z = 0.61187, n = 31, p-value = 0.5406
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01314265 0.03554773
## sample estimates:
## Sen's slope
## 0.006691773
Morrisey 5/22/2006
snotel_607 <- SNOTEL_yampa_area %>%
filter(site_id == "607")
#str(snotel_607) # check the date, usually a character.
snotel_607$Date <- as.Date(snotel_607$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_607_clean <- snotel_607 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_607_clean <- snotel_607_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_607_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_607_clean <- snotel_607_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40) %>%
filter(temperature_mean < 40)
ggplot(snotel_607_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_607_cull_count <- snotel_607_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_607_cull_count
# filtering for too few observations in a year
snotel_607_cull_count_days <- snotel_607_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_607_cull_count_days
## # A tibble: 4 x 2
## # Groups: waterYear [4]
## waterYear n
## <dbl> <int>
## 1 1985 1
## 2 1994 333
## 3 2019 284
## 4 2020 328
snotel_607_clean_culled <- snotel_607_clean %>%
filter(waterYear != "1985" & waterYear != "1986" & waterYear != "1994" & waterYear != "2019" & waterYear != "2020")# & waterYear != "2001" & waterYear != "2021")# & waterYear != "2021")# & waterYear != "1987" & waterYear != "1994" & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_607_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Also 1986
ggplot(snotel_607_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_607_xts <- xts(snotel_607_clean_culled$temperature_mean, order.by = snotel_607_clean_culled$Date)
dygraph(temp_607_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_607_clean_culled <- snotel_607_clean_culled %>%
# filter(temperature_mean > -30)
#temp_607_xts <- xts(snotel_607_clean_culled$temperature_mean, order.by = snotel_607_clean_culled$Date)
#dygraph(temp_607_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
snotel_607_adjusted <- snotel_607_clean_culled %>%
mutate(temp_ad = if_else(Date < "2006-05-22", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_607 <- snotel_607_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_607 <- yearly_wy_aver_607 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(temperature_mean))
#average mean temperature by day for the period of record:
daily_wy_aver_607 <- daily_wy_aver_607 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_607$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_607 <-daily_wy_aver_607 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_607$date_temp <- signif(daily_wy_aver2_607$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_607, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_607 <- daily_wy_aver_607 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_607 <- standard_dev_607 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_607 <- standard_dev_all_607 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_607 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.582343 |
| 1988 | 3.799577 |
| 1989 | 4.524159 |
| 1990 | 3.737210 |
| 1991 | 3.813672 |
| 1992 | 3.699350 |
| 1993 | 3.632591 |
| 1995 | 3.859395 |
| 1996 | 3.710483 |
| 1997 | 3.771008 |
| 1998 | 3.503283 |
| 1999 | 3.824894 |
| 2000 | 3.533504 |
| 2001 | 3.582864 |
| 2002 | 3.816826 |
| 2003 | 3.536193 |
| 2004 | 3.679508 |
| 2005 | 3.506615 |
| 2006 | 3.760379 |
| 2007 | 3.746644 |
| 2008 | 3.417203 |
| 2009 | 3.577805 |
| 2010 | 3.497146 |
| 2011 | 3.661059 |
| 2012 | 3.323317 |
| 2013 | 3.932274 |
| 2014 | 3.438441 |
| 2015 | 3.523553 |
| 2016 | 3.350197 |
| 2017 | 4.100477 |
| 2018 | 3.393477 |
| 2021 | 3.322497 |
| 2022 | 3.810463 |
ggplot(standard_dev_all_607, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 607 average temperatures for water years 2005-2021
sd_mk_607 <- mk.test(standard_dev_all_607$sd_2)
print(sd_mk_607)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_607$sd_2
## z = -2.5256, n = 33, p-value = 0.01155
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -164.0000000 4165.3333333 -0.3106061
sd_sens_607 <- sens.slope(standard_dev_all_607$sd_2)
print(sd_sens_607)
##
## Sen's slope
##
## data: standard_dev_all_607$sd_2
## z = -2.5256, n = 33, p-value = 0.01155
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.016751375 -0.002635498
## sample estimates:
## Sen's slope
## -0.01041114
#using the clean culled df:
#average water year temperature
yearly_wy_aver_607_ad <- snotel_607_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_607_ad <- yearly_wy_aver_607_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_607_ad <- daily_wy_aver_607_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_607_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_607_ad <-daily_wy_aver_607_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_607_ad$date_temp_ad <- signif(daily_wy_aver2_607_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_607_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_607_ad <- daily_wy_aver_607_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_607_ad <- standard_dev_607_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_607_ad <- standard_dev_all_607_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_607_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.409194 |
| 1988 | 3.565077 |
| 1989 | 4.368137 |
| 1990 | 3.559308 |
| 1991 | 3.665474 |
| 1992 | 3.525757 |
| 1993 | 3.473881 |
| 1995 | 3.689839 |
| 1996 | 3.530975 |
| 1997 | 3.600786 |
| 1998 | 3.287624 |
| 1999 | 3.679122 |
| 2000 | 3.342181 |
| 2001 | 3.340673 |
| 2002 | 3.548341 |
| 2003 | 3.327490 |
| 2004 | 3.504638 |
| 2005 | 3.361239 |
| 2006 | 3.607575 |
| 2007 | 3.776306 |
| 2008 | 3.433821 |
| 2009 | 3.506260 |
| 2010 | 3.536819 |
| 2011 | 3.653620 |
| 2012 | 3.347204 |
| 2013 | 3.985295 |
| 2014 | 3.414744 |
| 2015 | 3.445791 |
| 2016 | 3.336533 |
| 2017 | 4.044468 |
| 2018 | 3.362640 |
| 2021 | 3.365751 |
| 2022 | 3.812047 |
ggplot(standard_dev_all_607_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 607 average temperatures for water years 1986-2021
sd_mk_607_ad <- mk.test(standard_dev_all_607_ad$sd_2)
print(sd_mk_607_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_607_ad$sd_2
## z = -0.48033, n = 33, p-value = 0.631
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -32.00000000 4165.33333333 -0.06060606
sd_sens_607_ad <- sens.slope(standard_dev_all_607_ad$sd_2)
print(sd_sens_607_ad)
##
## Sen's slope
##
## data: standard_dev_all_607_ad$sd_2
## z = -0.48033, n = 33, p-value = 0.631
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.009259148 0.005363338
## sample estimates:
## Sen's slope
## -0.002065127
summer_standard_dev_all_607 <- standard_dev_607 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_607 <- summer_standard_dev_all_607 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_607 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.509021 |
| 1988 | 2.222165 |
| 1989 | 2.992402 |
| 1990 | 2.553451 |
| 1991 | 1.992289 |
| 1992 | 2.688367 |
| 1993 | 3.127050 |
| 1995 | 3.088004 |
| 1996 | 1.549095 |
| 1997 | 2.064332 |
| 1998 | 2.812535 |
| 1999 | 1.920085 |
| 2000 | 2.192247 |
| 2001 | 2.568610 |
| 2002 | 2.355194 |
| 2003 | 2.462296 |
| 2004 | 2.556924 |
| 2005 | 2.623972 |
| 2006 | 2.183401 |
| 2007 | 1.937866 |
| 2008 | 2.221198 |
| 2009 | 1.863362 |
| 2010 | 2.187224 |
| 2011 | 1.759141 |
| 2012 | 1.987729 |
| 2013 | 1.994614 |
| 2014 | 1.835703 |
| 2015 | 2.154568 |
| 2016 | 1.892683 |
| 2017 | 1.915960 |
| 2018 | 1.870595 |
| 2021 | 2.426265 |
| 2022 | 2.109108 |
ggplot(summer_standard_dev_all_607, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 607 average summer temperatures for water years 2005-2021
summer_sd_mk_607 <- mk.test(summer_standard_dev_all_607$sd_2)
print(summer_sd_mk_607)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_607$sd_2
## z = -2.9284, n = 33, p-value = 0.003407
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -190.0000000 4165.3333333 -0.3598485
summer_sd_sens_607 <- sens.slope(summer_standard_dev_all_607$sd_2)
print(summer_sd_sens_607)
##
## Sen's slope
##
## data: summer_standard_dev_all_607$sd_2
## z = -2.9284, n = 33, p-value = 0.003407
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.037019252 -0.005625506
## sample estimates:
## Sen's slope
## -0.02088598
Winter
winter_standard_dev_all_607 <- standard_dev_607 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_607 <- winter_standard_dev_all_607 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_607 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.305720 |
| 1988 | 4.460102 |
| 1989 | 5.690744 |
| 1990 | 4.537709 |
| 1991 | 4.697436 |
| 1992 | 3.796748 |
| 1993 | 4.306489 |
| 1995 | 4.712720 |
| 1996 | 4.514851 |
| 1997 | 4.508226 |
| 1998 | 4.093395 |
| 1999 | 4.609710 |
| 2000 | 3.982718 |
| 2001 | 4.090879 |
| 2002 | 4.449529 |
| 2003 | 4.212724 |
| 2004 | 4.253297 |
| 2005 | 4.410438 |
| 2006 | 4.726295 |
| 2007 | 4.809553 |
| 2008 | 4.164532 |
| 2009 | 4.295361 |
| 2010 | 4.110187 |
| 2011 | 4.787863 |
| 2012 | 4.030478 |
| 2013 | 4.982548 |
| 2014 | 3.965712 |
| 2015 | 4.385388 |
| 2016 | 4.275599 |
| 2017 | 5.062802 |
| 2018 | 4.230722 |
| 2021 | 3.862622 |
| 2022 | 4.712839 |
ggplot(winter_standard_dev_all_607, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 607 average winter temperatures for water years 2005-2021
winter_sd_mk_607 <- mk.test(winter_standard_dev_all_607$sd_2)
print(winter_sd_mk_607)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_607$sd_2
## z = -0.60428, n = 33, p-value = 0.5457
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -40.00000000 4165.33333333 -0.07575758
winter_sd_sens_607 <- sens.slope(winter_standard_dev_all_607$sd_2)
print(winter_sd_sens_607)
##
## Sen's slope
##
## data: winter_standard_dev_all_607$sd_2
## z = -0.60428, n = 33, p-value = 0.5457
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.0186793 0.0125724
## sample estimates:
## Sen's slope
## -0.005126594
Summer
summer_standard_dev_all_607_ad <- standard_dev_607_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_607_ad <- summer_standard_dev_all_607_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_607_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.262800 |
| 1988 | 2.000834 |
| 1989 | 2.676497 |
| 1990 | 2.300297 |
| 1991 | 1.794623 |
| 1992 | 2.422068 |
| 1993 | 2.828743 |
| 1995 | 2.783389 |
| 1996 | 1.392328 |
| 1997 | 1.863039 |
| 1998 | 2.515236 |
| 1999 | 1.713498 |
| 2000 | 1.977694 |
| 2001 | 2.308312 |
| 2002 | 2.109570 |
| 2003 | 2.181472 |
| 2004 | 2.303007 |
| 2005 | 2.333733 |
| 2006 | 2.170289 |
| 2007 | 1.958379 |
| 2008 | 2.237602 |
| 2009 | 1.876691 |
| 2010 | 2.176847 |
| 2011 | 1.747394 |
| 2012 | 1.965829 |
| 2013 | 1.971267 |
| 2014 | 1.837678 |
| 2015 | 2.120516 |
| 2016 | 1.868333 |
| 2017 | 1.892313 |
| 2018 | 1.863227 |
| 2021 | 2.403571 |
| 2022 | 2.095329 |
ggplot(summer_standard_dev_all_607_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 607 average summer temperatures for water years 1986-2021
summer_sd_mk_607_ad <- mk.test(summer_standard_dev_all_607_ad$sd_2)
print(summer_sd_mk_607_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_607_ad$sd_2
## z = -1.7509, n = 33, p-value = 0.07997
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -114.0000000 4165.3333333 -0.2159091
summer_sd_sens_607_ad <- sens.slope(summer_standard_dev_all_607_ad$sd_2)
print(summer_sd_sens_607_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_607_ad$sd_2
## z = -1.7509, n = 33, p-value = 0.07997
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.023533697 0.001463671
## sample estimates:
## Sen's slope
## -0.01124441
Winter
winter_standard_dev_all_607_ad <- standard_dev_607_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_607_ad <- winter_standard_dev_all_607_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_607_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.177345 |
| 1988 | 4.344783 |
| 1989 | 5.652759 |
| 1990 | 4.443225 |
| 1991 | 4.649356 |
| 1992 | 3.697415 |
| 1993 | 4.197014 |
| 1995 | 4.563932 |
| 1996 | 4.382884 |
| 1997 | 4.377624 |
| 1998 | 3.966891 |
| 1999 | 4.481500 |
| 2000 | 3.844152 |
| 2001 | 3.990893 |
| 2002 | 4.318338 |
| 2003 | 4.079920 |
| 2004 | 4.108444 |
| 2005 | 4.300802 |
| 2006 | 4.590842 |
| 2007 | 4.820500 |
| 2008 | 4.167629 |
| 2009 | 4.287540 |
| 2010 | 4.114648 |
| 2011 | 4.782795 |
| 2012 | 4.031624 |
| 2013 | 4.985186 |
| 2014 | 3.958921 |
| 2015 | 4.380114 |
| 2016 | 4.267320 |
| 2017 | 5.077411 |
| 2018 | 4.223291 |
| 2021 | 3.854595 |
| 2022 | 4.714411 |
ggplot(winter_standard_dev_all_607_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 607 average winter temperatures for water years 1986-2021
winter_sd_mk_607_ad <- mk.test(winter_standard_dev_all_607_ad$sd_2)
print(winter_sd_mk_607_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_607_ad$sd_2
## z = -0.015494, n = 33, p-value = 0.9876
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -2.000000e+00 4.165333e+03 -3.787879e-03
winter_sd_sens_607_ad <- sens.slope(winter_standard_dev_all_607_ad$sd_2)
print(winter_sd_sens_607_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_607_ad$sd_2
## z = -0.015494, n = 33, p-value = 0.9876
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01358995 0.01697849
## sample estimates:
## Sen's slope
## -0.0003158058
spring_standard_dev_all_607 <- standard_dev_607 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_607 <- spring_standard_dev_all_607 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_607 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.536935 |
| 1988 | 3.741158 |
| 1989 | 4.208508 |
| 1990 | 3.264941 |
| 1991 | 4.002397 |
| 1992 | 3.110778 |
| 1993 | 2.706393 |
| 1995 | 2.615104 |
| 1996 | 3.649116 |
| 1997 | 3.742304 |
| 1998 | 2.647594 |
| 1999 | 3.944615 |
| 2000 | 4.137037 |
| 2001 | 3.191799 |
| 2002 | 3.027891 |
| 2003 | 3.770674 |
| 2004 | 3.427380 |
| 2005 | 2.955982 |
| 2006 | 2.701304 |
| 2007 | 3.344855 |
| 2008 | 3.270017 |
| 2009 | 3.241549 |
| 2010 | 3.487281 |
| 2011 | 3.087082 |
| 2012 | 3.330254 |
| 2013 | 3.865477 |
| 2014 | 3.878616 |
| 2015 | 2.716340 |
| 2016 | 2.914506 |
| 2017 | 3.971535 |
| 2018 | 2.766661 |
| 2021 | 3.099893 |
| 2022 | 3.984099 |
ggplot(spring_standard_dev_all_607, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 607 average spring temperatures for water years 2005-2021
spring_sd_mk_607 <- mk.test(spring_standard_dev_all_607$sd_2)
print(spring_sd_mk_607)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_607$sd_2
## z = -0.48033, n = 33, p-value = 0.631
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -32.00000000 4165.33333333 -0.06060606
spring_sd_sens_607 <- sens.slope(spring_standard_dev_all_607$sd_2)
print(spring_sd_sens_607)
##
## Sen's slope
##
## data: spring_standard_dev_all_607$sd_2
## z = -0.48033, n = 33, p-value = 0.631
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.0284678 0.0127500
## sample estimates:
## Sen's slope
## -0.006997144
Fall
fall_standard_dev_all_607 <- standard_dev_607 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_607 <- fall_standard_dev_all_607 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_607 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.762905 |
| 1988 | 3.258769 |
| 1989 | 2.840806 |
| 1990 | 3.499392 |
| 1991 | 3.217332 |
| 1992 | 4.164700 |
| 1993 | 3.139776 |
| 1995 | 3.035229 |
| 1996 | 3.646304 |
| 1997 | 3.716753 |
| 1998 | 3.578994 |
| 1999 | 3.052388 |
| 2000 | 3.173598 |
| 2001 | 2.856232 |
| 2002 | 2.930051 |
| 2003 | 2.292158 |
| 2004 | 3.431995 |
| 2005 | 2.515351 |
| 2006 | 2.855254 |
| 2007 | 2.953376 |
| 2008 | 2.794251 |
| 2009 | 3.181423 |
| 2010 | 3.490638 |
| 2011 | 2.600636 |
| 2012 | 2.648559 |
| 2013 | 2.967596 |
| 2014 | 3.304237 |
| 2015 | 2.717718 |
| 2016 | 2.491811 |
| 2017 | 3.392230 |
| 2018 | 3.039880 |
| 2021 | 3.046626 |
| 2022 | 2.910269 |
ggplot(fall_standard_dev_all_607, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 607 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_607 <- mk.test(fall_standard_dev_all_607$sd_2)
print(fall_sd_mk_607)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_607$sd_2
## z = -1.6269, n = 33, p-value = 0.1038
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -106.0000000 4165.3333333 -0.2007576
fall_sd_sens_607 <- sens.slope(fall_standard_dev_all_607$sd_2)
print(fall_sd_sens_607)
##
## Sen's slope
##
## data: fall_standard_dev_all_607$sd_2
## z = -1.6269, n = 33, p-value = 0.1038
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.028149221 0.002844073
## sample estimates:
## Sen's slope
## -0.01329466
Spring
spring_standard_dev_all_607_ad <- standard_dev_607_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_607_ad <- spring_standard_dev_all_607_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_607_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.260283 |
| 1988 | 3.437487 |
| 1989 | 3.878689 |
| 1990 | 3.032910 |
| 1991 | 3.688092 |
| 1992 | 2.867862 |
| 1993 | 2.485990 |
| 1995 | 2.449444 |
| 1996 | 3.358340 |
| 1997 | 3.484411 |
| 1998 | 2.393530 |
| 1999 | 3.649176 |
| 2000 | 3.775712 |
| 2001 | 2.929607 |
| 2002 | 2.785401 |
| 2003 | 3.441423 |
| 2004 | 3.147513 |
| 2005 | 2.700594 |
| 2006 | 2.499929 |
| 2007 | 3.330419 |
| 2008 | 3.316341 |
| 2009 | 3.279967 |
| 2010 | 3.503983 |
| 2011 | 3.066010 |
| 2012 | 3.282069 |
| 2013 | 3.901010 |
| 2014 | 3.894027 |
| 2015 | 2.650359 |
| 2016 | 2.888094 |
| 2017 | 3.928364 |
| 2018 | 2.796806 |
| 2021 | 3.104692 |
| 2022 | 3.973703 |
ggplot(spring_standard_dev_all_607_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 607 average spring temperatures for water years 1986-2021
spring_sd_mk_607_ad <- mk.test(spring_standard_dev_all_607_ad$sd_2)
print(spring_sd_mk_607_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_607_ad$sd_2
## z = 0.60428, n = 33, p-value = 0.5457
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 4.000000e+01 4.165333e+03 7.575758e-02
spring_sd_sens_607_ad <- sens.slope(spring_standard_dev_all_607_ad$sd_2)
print(spring_sd_sens_607_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_607_ad$sd_2
## z = 0.60428, n = 33, p-value = 0.5457
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01703698 0.02474808
## sample estimates:
## Sen's slope
## 0.006352082
Fall
fall_standard_dev_all_607_ad <- standard_dev_607_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_607_ad <- fall_standard_dev_all_607_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_607_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.558069 |
| 1988 | 3.011138 |
| 1989 | 2.626619 |
| 1990 | 3.160763 |
| 1991 | 2.967966 |
| 1992 | 3.872921 |
| 1993 | 2.933684 |
| 1995 | 2.752599 |
| 1996 | 3.368412 |
| 1997 | 3.410403 |
| 1998 | 3.224511 |
| 1999 | 2.851718 |
| 2000 | 2.891918 |
| 2001 | 2.614152 |
| 2002 | 2.714288 |
| 2003 | 2.103480 |
| 2004 | 3.194405 |
| 2005 | 2.316253 |
| 2006 | 2.922116 |
| 2007 | 3.031155 |
| 2008 | 2.740938 |
| 2009 | 3.181195 |
| 2010 | 3.529566 |
| 2011 | 2.599997 |
| 2012 | 2.686942 |
| 2013 | 3.005285 |
| 2014 | 3.332121 |
| 2015 | 2.653992 |
| 2016 | 2.442224 |
| 2017 | 3.348174 |
| 2018 | 3.077504 |
| 2021 | 3.027465 |
| 2022 | 2.960297 |
ggplot(fall_standard_dev_all_607_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 607 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_607_ad <- mk.test(fall_standard_dev_all_607_ad$sd_2)
print(fall_sd_mk_607_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_607_ad$sd_2
## z = -0.077472, n = 33, p-value = 0.9382
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -6.00000000 4165.33333333 -0.01136364
fall_sd_sens_607_ad <- sens.slope(fall_standard_dev_all_607_ad$sd_2)
print(fall_sd_sens_607_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_607_ad$sd_2
## z = -0.077472, n = 33, p-value = 0.9382
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01477973 0.01283930
## sample estimates:
## Sen's slope
## -0.0006022318
Morrisey 8/7/2006
snotel_709 <- SNOTEL_yampa_area %>%
filter(site_id == "709")
#str(snotel_709) # check the date, usually a character.
snotel_709$Date <- as.Date(snotel_709$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_709_clean <- snotel_709 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_709_clean <- snotel_709_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_709_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_709_clean <- snotel_709_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40) %>%
filter(temperature_mean < 40)
ggplot(snotel_709_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_709_cull_count <- snotel_709_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_709_cull_count
# filtering for too few observations in a year
snotel_709_cull_count_days <- snotel_709_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_709_cull_count_days
## # A tibble: 14 x 2
## # Groups: waterYear [14]
## waterYear n
## <dbl> <int>
## 1 1992 318
## 2 1993 293
## 3 1994 332
## 4 1995 169
## 5 2006 348
## 6 2007 311
## 7 2011 292
## 8 2012 308
## 9 2013 300
## 10 2014 283
## 11 2015 44
## 12 2016 18
## 13 2017 34
## 14 2018 147
snotel_709_clean_culled <- snotel_709_clean %>%
filter(waterYear > "1995" & waterYear != "2006" & waterYear != "2007" & waterYear != "2011" & waterYear != "2012" & waterYear != "2013" & waterYear != "2014" & waterYear != "2015" & waterYear != "2016" & waterYear != "2017" & waterYear != "2018")# & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_709_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
ggplot(snotel_709_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_709_xts <- xts(snotel_709_clean_culled$temperature_mean, order.by = snotel_709_clean_culled$Date)
dygraph(temp_709_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_709_clean_culled <- snotel_709_clean_culled %>%
# filter(temperature_mean > -30)
#temp_709_xts <- xts(snotel_709_clean_culled$temperature_mean, order.by = snotel_709_clean_culled$Date)
#dygraph(temp_709_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
snotel_709_adjusted <- snotel_709_clean_culled %>%
mutate(temp_ad = if_else(Date < "2006-08-07", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_709 <- snotel_709_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_709 <- yearly_wy_aver_709 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(temperature_mean))
#average mean temperature by day for the period of record:
daily_wy_aver_709 <- daily_wy_aver_709 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_709$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_709 <-daily_wy_aver_709 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_709$date_temp <- signif(daily_wy_aver2_709$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_709, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_709 <- daily_wy_aver_709 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_709 <- standard_dev_709 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_709 <- standard_dev_all_709 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_709 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 4.046429 |
| 1997 | 4.039956 |
| 1998 | 3.603214 |
| 1999 | 4.110191 |
| 2000 | 3.917364 |
| 2001 | 3.864370 |
| 2002 | 3.983878 |
| 2003 | 3.694470 |
| 2004 | 4.063015 |
| 2005 | 3.645949 |
| 2008 | 3.750942 |
| 2009 | 3.755342 |
| 2010 | 3.897555 |
| 2019 | 3.594822 |
| 2020 | 4.019790 |
| 2021 | 3.795834 |
| 2022 | 4.013440 |
ggplot(standard_dev_all_709, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 709 average temperatures for water years 2005-2021
sd_mk_709 <- mk.test(standard_dev_all_709$sd_2)
print(sd_mk_709)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_709$sd_2
## z = -0.86505, n = 17, p-value = 0.387
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -22.0000000 589.3333333 -0.1617647
sd_sens_709 <- sens.slope(standard_dev_all_709$sd_2)
print(sd_sens_709)
##
## Sen's slope
##
## data: standard_dev_all_709$sd_2
## z = -0.86505, n = 17, p-value = 0.387
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03211267 0.01481691
## sample estimates:
## Sen's slope
## -0.007323263
#using the clean culled df:
#average water year temperature
yearly_wy_aver_709_ad <- snotel_709_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_709_ad <- yearly_wy_aver_709_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_709_ad <- daily_wy_aver_709_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_709_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_709_ad <-daily_wy_aver_709_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_709_ad$date_temp_ad <- signif(daily_wy_aver2_709_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_709_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_709_ad <- daily_wy_aver_709_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_709_ad <- standard_dev_709_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_709_ad <- standard_dev_all_709_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_709_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 3.846082 |
| 1997 | 3.846388 |
| 1998 | 3.374129 |
| 1999 | 3.941368 |
| 2000 | 3.683076 |
| 2001 | 3.602903 |
| 2002 | 3.708201 |
| 2003 | 3.456346 |
| 2004 | 3.852331 |
| 2005 | 3.467358 |
| 2008 | 3.776391 |
| 2009 | 3.691358 |
| 2010 | 3.912619 |
| 2019 | 3.608731 |
| 2020 | 4.047964 |
| 2021 | 3.821569 |
| 2022 | 3.998666 |
ggplot(standard_dev_all_709_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 709 average temperatures for water years 1986-2021
sd_mk_709_ad <- mk.test(standard_dev_all_709_ad$sd_2)
print(sd_mk_709_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_709_ad$sd_2
## z = 1.1946, n = 17, p-value = 0.2322
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 30.0000000 589.3333333 0.2205882
sd_sens_709_ad <- sens.slope(standard_dev_all_709_ad$sd_2)
print(sd_sens_709_ad)
##
## Sen's slope
##
## data: standard_dev_all_709_ad$sd_2
## z = 1.1946, n = 17, p-value = 0.2322
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01406580 0.03534324
## sample estimates:
## Sen's slope
## 0.01259339
summer_standard_dev_all_709 <- standard_dev_709 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_709 <- summer_standard_dev_all_709 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_709 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 1.798172 |
| 1997 | 2.581032 |
| 1998 | 2.950365 |
| 1999 | 2.075320 |
| 2000 | 2.584201 |
| 2001 | 3.028438 |
| 2002 | 2.885638 |
| 2003 | 2.760048 |
| 2004 | 2.958099 |
| 2005 | 3.021450 |
| 2008 | 2.580371 |
| 2009 | 2.282856 |
| 2010 | 2.413484 |
| 2019 | 2.541279 |
| 2020 | 2.793659 |
| 2021 | 3.288074 |
| 2022 | 2.423721 |
ggplot(summer_standard_dev_all_709, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 709 average summer temperatures for water years 2005-2021
summer_sd_mk_709 <- mk.test(summer_standard_dev_all_709$sd_2)
print(summer_sd_mk_709)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_709$sd_2
## z = 0.45312, n = 17, p-value = 0.6505
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 12.00000000 589.33333333 0.08823529
summer_sd_sens_709 <- sens.slope(summer_standard_dev_all_709$sd_2)
print(summer_sd_sens_709)
##
## Sen's slope
##
## data: summer_standard_dev_all_709$sd_2
## z = 0.45312, n = 17, p-value = 0.6505
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03646145 0.06092116
## sample estimates:
## Sen's slope
## 0.01865082
Winter
winter_standard_dev_all_709 <- standard_dev_709 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_709 <- winter_standard_dev_all_709 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_709 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 4.501936 |
| 1997 | 4.613454 |
| 1998 | 3.995501 |
| 1999 | 4.729453 |
| 2000 | 4.078328 |
| 2001 | 4.144973 |
| 2002 | 4.375561 |
| 2003 | 3.993018 |
| 2004 | 4.319516 |
| 2005 | 4.156150 |
| 2008 | 4.301765 |
| 2009 | 4.435250 |
| 2010 | 4.226483 |
| 2019 | 3.994256 |
| 2020 | 3.779755 |
| 2021 | 3.934384 |
| 2022 | 4.695839 |
ggplot(winter_standard_dev_all_709, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 709 average winter temperatures for water years 2005-2021
winter_sd_mk_709 <- mk.test(winter_standard_dev_all_709$sd_2)
print(winter_sd_mk_709)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_709$sd_2
## z = -1.1946, n = 17, p-value = 0.2322
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -30.0000000 589.3333333 -0.2205882
winter_sd_sens_709 <- sens.slope(winter_standard_dev_all_709$sd_2)
print(winter_sd_sens_709)
##
## Sen's slope
##
## data: winter_standard_dev_all_709$sd_2
## z = -1.1946, n = 17, p-value = 0.2322
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.05158440 0.02309819
## sample estimates:
## Sen's slope
## -0.02106068
Summer
summer_standard_dev_all_709_ad <- standard_dev_709_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_709_ad <- summer_standard_dev_all_709_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_709_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 1.622328 |
| 1997 | 2.341696 |
| 1998 | 2.632811 |
| 1999 | 1.873769 |
| 2000 | 2.338610 |
| 2001 | 2.744766 |
| 2002 | 2.617040 |
| 2003 | 2.432490 |
| 2004 | 2.678525 |
| 2005 | 2.690760 |
| 2008 | 2.599563 |
| 2009 | 2.296096 |
| 2010 | 2.397384 |
| 2019 | 2.559431 |
| 2020 | 2.755521 |
| 2021 | 3.214722 |
| 2022 | 2.387394 |
ggplot(summer_standard_dev_all_709_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 709 average summer temperatures for water years 1986-2021
summer_sd_mk_709_ad <- mk.test(summer_standard_dev_all_709_ad$sd_2)
print(summer_sd_mk_709_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_709_ad$sd_2
## z = 1.5241, n = 17, p-value = 0.1275
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 38.0000000 589.3333333 0.2794118
summer_sd_sens_709_ad <- sens.slope(summer_standard_dev_all_709_ad$sd_2)
print(summer_sd_sens_709_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_709_ad$sd_2
## z = 1.5241, n = 17, p-value = 0.1275
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.004559968 0.072084836
## sample estimates:
## Sen's slope
## 0.0296972
Winter
winter_standard_dev_all_709_ad <- standard_dev_709_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_709_ad <- winter_standard_dev_all_709_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_709_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 4.357677 |
| 1997 | 4.463267 |
| 1998 | 3.865908 |
| 1999 | 4.568776 |
| 2000 | 3.890382 |
| 2001 | 4.031648 |
| 2002 | 4.229187 |
| 2003 | 3.858395 |
| 2004 | 4.163530 |
| 2005 | 4.026833 |
| 2008 | 4.310811 |
| 2009 | 4.427496 |
| 2010 | 4.229217 |
| 2019 | 3.977640 |
| 2020 | 3.780200 |
| 2021 | 3.922802 |
| 2022 | 4.693983 |
ggplot(winter_standard_dev_all_709_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 709 average winter temperatures for water years 1986-2021
winter_sd_mk_709_ad <- mk.test(winter_standard_dev_all_709_ad$sd_2)
print(winter_sd_mk_709_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_709_ad$sd_2
## z = -0.37073, n = 17, p-value = 0.7108
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -10.00000000 589.33333333 -0.07352941
winter_sd_sens_709_ad <- sens.slope(winter_standard_dev_all_709_ad$sd_2)
print(winter_sd_sens_709_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_709_ad$sd_2
## z = -0.37073, n = 17, p-value = 0.7108
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03772869 0.04235444
## sample estimates:
## Sen's slope
## -0.006946645
spring_standard_dev_all_709 <- standard_dev_709 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_709 <- spring_standard_dev_all_709 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_709 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 4.392525 |
| 1997 | 3.979770 |
| 1998 | 3.287391 |
| 1999 | 4.396265 |
| 2000 | 4.698179 |
| 2001 | 3.870953 |
| 2002 | 3.612179 |
| 2003 | 4.491124 |
| 2004 | 4.167010 |
| 2005 | 3.897487 |
| 2008 | 3.728142 |
| 2009 | 3.468541 |
| 2010 | 4.289775 |
| 2019 | 3.872565 |
| 2020 | 3.990448 |
| 2021 | 3.789377 |
| 2022 | 4.306624 |
ggplot(spring_standard_dev_all_709, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 709 average spring temperatures for water years 2005-2021
spring_sd_mk_709 <- mk.test(spring_standard_dev_all_709$sd_2)
print(spring_sd_mk_709)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_709$sd_2
## z = -0.45312, n = 17, p-value = 0.6505
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -12.00000000 589.33333333 -0.08823529
spring_sd_sens_709 <- sens.slope(spring_standard_dev_all_709$sd_2)
print(spring_sd_sens_709)
##
## Sen's slope
##
## data: spring_standard_dev_all_709$sd_2
## z = -0.45312, n = 17, p-value = 0.6505
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.05500423 0.03719803
## sample estimates:
## Sen's slope
## -0.009609552
Fall
fall_standard_dev_all_709 <- standard_dev_709 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_709 <- fall_standard_dev_all_709 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_709 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 4.724749 |
| 1997 | 4.272893 |
| 1998 | 3.639717 |
| 1999 | 3.877520 |
| 2000 | 4.287897 |
| 2001 | 3.487207 |
| 2002 | 3.745845 |
| 2003 | 2.892469 |
| 2004 | 4.324309 |
| 2005 | 2.740906 |
| 2008 | 3.758002 |
| 2009 | 3.389929 |
| 2010 | 4.415185 |
| 2019 | 3.613747 |
| 2020 | 5.551894 |
| 2021 | 4.097061 |
| 2022 | 3.580181 |
ggplot(fall_standard_dev_all_709, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 709 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_709 <- mk.test(fall_standard_dev_all_709$sd_2)
print(fall_sd_mk_709)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_709$sd_2
## z = -0.45312, n = 17, p-value = 0.6505
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -12.00000000 589.33333333 -0.08823529
fall_sd_sens_709 <- sens.slope(fall_standard_dev_all_709$sd_2)
print(fall_sd_sens_709)
##
## Sen's slope
##
## data: fall_standard_dev_all_709$sd_2
## z = -0.45312, n = 17, p-value = 0.6505
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.08829641 0.06098540
## sample estimates:
## Sen's slope
## -0.01682022
Spring
spring_standard_dev_all_709_ad <- standard_dev_709_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_709_ad <- spring_standard_dev_all_709_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_709_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 4.076432 |
| 1997 | 3.718638 |
| 1998 | 2.996424 |
| 1999 | 4.095541 |
| 2000 | 4.329527 |
| 2001 | 3.566542 |
| 2002 | 3.333462 |
| 2003 | 4.140158 |
| 2004 | 3.859844 |
| 2005 | 3.607138 |
| 2008 | 3.761801 |
| 2009 | 3.474898 |
| 2010 | 4.287627 |
| 2019 | 3.802435 |
| 2020 | 4.001186 |
| 2021 | 3.784079 |
| 2022 | 4.282196 |
ggplot(spring_standard_dev_all_709_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 709 average spring temperatures for water years 1986-2021
spring_sd_mk_709_ad <- mk.test(spring_standard_dev_all_709_ad$sd_2)
print(spring_sd_mk_709_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_709_ad$sd_2
## z = 0.70027, n = 17, p-value = 0.4838
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 18.0000000 589.3333333 0.1323529
spring_sd_sens_709_ad <- sens.slope(spring_standard_dev_all_709_ad$sd_2)
print(spring_sd_sens_709_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_709_ad$sd_2
## z = 0.70027, n = 17, p-value = 0.4838
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02707345 0.06505950
## sample estimates:
## Sen's slope
## 0.01320254
Fall
fall_standard_dev_all_709_ad <- standard_dev_709_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_709_ad <- fall_standard_dev_all_709_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_709_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1996 | 4.395293 |
| 1997 | 3.948034 |
| 1998 | 3.280831 |
| 1999 | 3.640720 |
| 2000 | 3.974748 |
| 2001 | 3.196307 |
| 2002 | 3.476675 |
| 2003 | 2.663726 |
| 2004 | 4.028859 |
| 2005 | 2.514890 |
| 2008 | 3.673576 |
| 2009 | 3.379781 |
| 2010 | 4.443400 |
| 2019 | 3.643612 |
| 2020 | 5.616771 |
| 2021 | 4.119851 |
| 2022 | 3.600881 |
ggplot(fall_standard_dev_all_709_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 709 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_709_ad <- mk.test(fall_standard_dev_all_709_ad$sd_2)
print(fall_sd_mk_709_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_709_ad$sd_2
## z = 0.45312, n = 17, p-value = 0.6505
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 12.00000000 589.33333333 0.08823529
fall_sd_sens_709_ad <- sens.slope(fall_standard_dev_all_709_ad$sd_2)
print(fall_sd_sens_709_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_709_ad$sd_2
## z = 0.45312, n = 17, p-value = 0.6505
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.05682529 0.09235443
## sample estimates:
## Sen's slope
## 0.01190958
Oyler -> Morrisey 8/7/2006
snotel_717 <- SNOTEL_yampa_area %>%
filter(site_id == "717")
#str(snotel_717) # check the date, usually a character.
snotel_717$Date <- as.Date(snotel_717$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_717_clean <- snotel_717 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_717_clean <- snotel_717_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_717_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_717_clean <- snotel_717_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40) %>%
filter(temperature_mean < 40)
ggplot(snotel_717_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_717_cull_count <- snotel_717_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_717_cull_count
# filtering for too few observations in a year
snotel_717_cull_count_days <- snotel_717_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_717_cull_count_days
## # A tibble: 2 x 2
## # Groups: waterYear [2]
## waterYear n
## <dbl> <int>
## 1 1992 311
## 2 1993 330
snotel_717_clean_culled <- snotel_717_clean %>%
filter(waterYear != "1992" & waterYear != "1993")# & waterYear != "2007" & waterYear != "2011" & waterYear != "2012" & waterYear != "2013" & waterYear != "2014" & waterYear != "2015" & waterYear != "2016" & waterYear != "2017" & waterYear != "2018")# & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_717_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
ggplot(snotel_717_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_717_xts <- xts(snotel_717_clean_culled$temperature_mean, order.by = snotel_717_clean_culled$Date)
dygraph(temp_717_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_717_clean_culled <- snotel_717_clean_culled %>%
# filter(temperature_mean > -30)
#temp_717_xts <- xts(snotel_717_clean_culled$temperature_mean, order.by = snotel_717_clean_culled$Date)
#dygraph(temp_717_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
snotel_717_adjusted <- snotel_717_clean_culled %>%
mutate(temp_ad = if_else(Date < "2006-08-07", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_717 <- snotel_717_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_717 <- yearly_wy_aver_717 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(temperature_mean))
#average mean temperature by day for the period of record:
daily_wy_aver_717 <- daily_wy_aver_717 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_717$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_717 <-daily_wy_aver_717 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_717$date_temp <- signif(daily_wy_aver2_717$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_717, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_717 <- daily_wy_aver_717 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_717 <- standard_dev_717 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_717 <- standard_dev_all_717 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_717 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.992946 |
| 1988 | 4.081187 |
| 1989 | 4.268444 |
| 1990 | 3.883613 |
| 1991 | 3.974438 |
| 1994 | 3.840813 |
| 1995 | 4.082652 |
| 1996 | 3.962314 |
| 1997 | 3.927417 |
| 1998 | 3.701477 |
| 1999 | 3.993733 |
| 2000 | 4.010976 |
| 2001 | 3.808629 |
| 2002 | 3.974543 |
| 2003 | 3.790376 |
| 2004 | 4.027345 |
| 2005 | 3.654554 |
| 2006 | 4.108348 |
| 2007 | 3.948026 |
| 2008 | 3.836531 |
| 2009 | 3.765057 |
| 2010 | 3.804487 |
| 2011 | 3.866990 |
| 2012 | 3.662769 |
| 2013 | 4.076981 |
| 2014 | 3.762042 |
| 2015 | 3.936033 |
| 2016 | 3.526473 |
| 2017 | 4.156233 |
| 2018 | 3.516048 |
| 2019 | 3.526563 |
| 2020 | 3.954049 |
| 2021 | 3.859996 |
| 2022 | 4.067130 |
ggplot(standard_dev_all_717, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 717 average temperatures for water years 2005-2021
sd_mk_717 <- mk.test(standard_dev_all_717$sd_2)
print(sd_mk_717)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_717$sd_2
## z = -1.9568, n = 34, p-value = 0.05037
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -133.0000000 4550.3333333 -0.2370766
sd_sens_717 <- sens.slope(standard_dev_all_717$sd_2)
print(sd_sens_717)
##
## Sen's slope
##
## data: standard_dev_all_717$sd_2
## z = -1.9568, n = 34, p-value = 0.05037
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -1.417852e-02 1.170191e-05
## sample estimates:
## Sen's slope
## -0.006354918
#using the clean culled df:
#average water year temperature
yearly_wy_aver_717_ad <- snotel_717_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_717_ad <- yearly_wy_aver_717_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_717_ad <- daily_wy_aver_717_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_717_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_717_ad <-daily_wy_aver_717_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_717_ad$date_temp_ad <- signif(daily_wy_aver2_717_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_717_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_717_ad <- daily_wy_aver_717_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_717_ad <- standard_dev_717_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_717_ad <- standard_dev_all_717_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_717_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.782725 |
| 1988 | 3.822012 |
| 1989 | 4.062405 |
| 1990 | 3.649173 |
| 1991 | 3.803469 |
| 1994 | 3.610143 |
| 1995 | 3.895253 |
| 1996 | 3.761608 |
| 1997 | 3.737641 |
| 1998 | 3.474078 |
| 1999 | 3.844055 |
| 2000 | 3.789521 |
| 2001 | 3.570768 |
| 2002 | 3.706119 |
| 2003 | 3.546337 |
| 2004 | 3.836887 |
| 2005 | 3.488400 |
| 2006 | 3.954787 |
| 2007 | 3.961826 |
| 2008 | 3.862141 |
| 2009 | 3.715647 |
| 2010 | 3.811776 |
| 2011 | 3.867504 |
| 2012 | 3.665082 |
| 2013 | 4.099951 |
| 2014 | 3.741901 |
| 2015 | 3.858066 |
| 2016 | 3.516673 |
| 2017 | 4.110060 |
| 2018 | 3.494338 |
| 2019 | 3.540473 |
| 2020 | 3.980586 |
| 2021 | 3.885063 |
| 2022 | 4.059626 |
ggplot(standard_dev_all_717_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 717 average temperatures for water years 1986-2021
sd_mk_717_ad <- mk.test(standard_dev_all_717_ad$sd_2)
print(sd_mk_717_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_717_ad$sd_2
## z = 0.88947, n = 34, p-value = 0.3738
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 61.0000000 4550.3333333 0.1087344
sd_sens_717_ad <- sens.slope(standard_dev_all_717_ad$sd_2)
print(sd_sens_717_ad)
##
## Sen's slope
##
## data: standard_dev_all_717_ad$sd_2
## z = 0.88947, n = 34, p-value = 0.3738
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.004837281 0.009372664
## sample estimates:
## Sen's slope
## 0.002527203
summer_standard_dev_all_717 <- standard_dev_717 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_717 <- summer_standard_dev_all_717 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_717 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.143471 |
| 1988 | 2.329515 |
| 1989 | 3.133187 |
| 1990 | 3.173442 |
| 1991 | 2.514904 |
| 1994 | 2.554514 |
| 1995 | 3.707395 |
| 1996 | 1.949616 |
| 1997 | 2.413608 |
| 1998 | 3.297268 |
| 1999 | 2.083035 |
| 2000 | 2.628543 |
| 2001 | 2.921813 |
| 2002 | 2.746366 |
| 2003 | 2.993916 |
| 2004 | 2.886182 |
| 2005 | 3.143443 |
| 2006 | 2.896111 |
| 2007 | 2.450509 |
| 2008 | 2.563005 |
| 2009 | 2.410173 |
| 2010 | 2.308791 |
| 2011 | 2.264653 |
| 2012 | 2.381496 |
| 2013 | 2.189274 |
| 2014 | 2.354949 |
| 2015 | 2.582685 |
| 2016 | 2.278792 |
| 2017 | 2.085138 |
| 2018 | 2.281696 |
| 2019 | 2.619712 |
| 2020 | 2.751195 |
| 2021 | 3.242236 |
| 2022 | 2.424182 |
ggplot(summer_standard_dev_all_717, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 717 average summer temperatures for water years 2005-2021
summer_sd_mk_717 <- mk.test(summer_standard_dev_all_717$sd_2)
print(summer_sd_mk_717)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_717$sd_2
## z = -1.7493, n = 34, p-value = 0.08024
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -119.0000000 4550.3333333 -0.2121212
summer_sd_sens_717 <- sens.slope(summer_standard_dev_all_717$sd_2)
print(summer_sd_sens_717)
##
## Sen's slope
##
## data: summer_standard_dev_all_717$sd_2
## z = -1.7493, n = 34, p-value = 0.08024
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.031536692 0.001341484
## sample estimates:
## Sen's slope
## -0.01427771
Winter
winter_standard_dev_all_717 <- standard_dev_717 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_717 <- winter_standard_dev_all_717 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_717 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.499203 |
| 1988 | 4.475411 |
| 1989 | 5.077805 |
| 1990 | 4.217163 |
| 1991 | 4.761805 |
| 1994 | 4.503071 |
| 1995 | 4.619426 |
| 1996 | 4.372782 |
| 1997 | 4.307120 |
| 1998 | 3.968149 |
| 1999 | 4.523894 |
| 2000 | 4.413746 |
| 2001 | 4.134155 |
| 2002 | 4.394665 |
| 2003 | 3.966590 |
| 2004 | 4.427422 |
| 2005 | 4.205895 |
| 2006 | 4.851298 |
| 2007 | 4.783357 |
| 2008 | 4.407971 |
| 2009 | 4.458470 |
| 2010 | 4.115693 |
| 2011 | 4.810093 |
| 2012 | 4.294137 |
| 2013 | 5.036856 |
| 2014 | 4.131160 |
| 2015 | 4.636826 |
| 2016 | 4.267271 |
| 2017 | 4.834320 |
| 2018 | 4.134957 |
| 2019 | 4.038126 |
| 2020 | 3.885231 |
| 2021 | 4.108951 |
| 2022 | 4.744366 |
ggplot(winter_standard_dev_all_717, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 717 average winter temperatures for water years 2005-2021
winter_sd_mk_717 <- mk.test(winter_standard_dev_all_717$sd_2)
print(winter_sd_mk_717)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_717$sd_2
## z = -1.3046, n = 34, p-value = 0.192
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -89.0000000 4550.3333333 -0.1586453
winter_sd_sens_717 <- sens.slope(winter_standard_dev_all_717$sd_2)
print(winter_sd_sens_717)
##
## Sen's slope
##
## data: winter_standard_dev_all_717$sd_2
## z = -1.3046, n = 34, p-value = 0.192
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.018331767 0.005096296
## sample estimates:
## Sen's slope
## -0.008005424
Summer
summer_standard_dev_all_717_ad <- standard_dev_717_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_717_ad <- summer_standard_dev_all_717_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_717_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.837065 |
| 1988 | 2.093151 |
| 1989 | 2.798815 |
| 1990 | 2.860679 |
| 1991 | 2.267217 |
| 1994 | 2.310820 |
| 1995 | 3.340008 |
| 1996 | 1.750528 |
| 1997 | 2.176964 |
| 1998 | 2.946304 |
| 1999 | 1.861239 |
| 2000 | 2.373269 |
| 2001 | 2.640689 |
| 2002 | 2.474230 |
| 2003 | 2.649636 |
| 2004 | 2.607153 |
| 2005 | 2.797558 |
| 2006 | 2.701214 |
| 2007 | 2.466229 |
| 2008 | 2.590996 |
| 2009 | 2.445613 |
| 2010 | 2.309029 |
| 2011 | 2.270348 |
| 2012 | 2.339717 |
| 2013 | 2.154672 |
| 2014 | 2.354070 |
| 2015 | 2.549937 |
| 2016 | 2.245147 |
| 2017 | 2.057727 |
| 2018 | 2.260666 |
| 2019 | 2.640724 |
| 2020 | 2.744352 |
| 2021 | 3.200351 |
| 2022 | 2.401328 |
ggplot(summer_standard_dev_all_717_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 717 average summer temperatures for water years 1986-2021
summer_sd_mk_717_ad <- mk.test(summer_standard_dev_all_717_ad$sd_2)
print(summer_sd_mk_717_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_717_ad$sd_2
## z = -0.62263, n = 34, p-value = 0.5335
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -43.00000000 4550.33333333 -0.07664884
summer_sd_sens_717_ad <- sens.slope(summer_standard_dev_all_717_ad$sd_2)
print(summer_sd_sens_717_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_717_ad$sd_2
## z = -0.62263, n = 34, p-value = 0.5335
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01918573 0.01114975
## sample estimates:
## Sen's slope
## -0.004088186
Winter
winter_standard_dev_all_717_ad <- standard_dev_717_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_717_ad <- winter_standard_dev_all_717_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_717_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.367624 |
| 1988 | 4.363759 |
| 1989 | 4.960980 |
| 1990 | 4.100642 |
| 1991 | 4.672601 |
| 1994 | 4.400390 |
| 1995 | 4.476852 |
| 1996 | 4.247078 |
| 1997 | 4.163653 |
| 1998 | 3.852083 |
| 1999 | 4.384472 |
| 2000 | 4.234482 |
| 2001 | 4.043977 |
| 2002 | 4.267181 |
| 2003 | 3.856679 |
| 2004 | 4.286247 |
| 2005 | 4.098262 |
| 2006 | 4.733071 |
| 2007 | 4.791416 |
| 2008 | 4.418437 |
| 2009 | 4.453741 |
| 2010 | 4.119044 |
| 2011 | 4.809006 |
| 2012 | 4.291916 |
| 2013 | 5.036775 |
| 2014 | 4.128885 |
| 2015 | 4.631930 |
| 2016 | 4.261038 |
| 2017 | 4.845159 |
| 2018 | 4.128668 |
| 2019 | 4.027230 |
| 2020 | 3.888800 |
| 2021 | 4.104457 |
| 2022 | 4.743054 |
ggplot(winter_standard_dev_all_717_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 717 average winter temperatures for water years 1986-2021
winter_sd_mk_717_ad <- mk.test(winter_standard_dev_all_717_ad$sd_2)
print(winter_sd_mk_717_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_717_ad$sd_2
## z = -0.23719, n = 34, p-value = 0.8125
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -17.00000000 4550.33333333 -0.03030303
winter_sd_sens_717_ad <- sens.slope(winter_standard_dev_all_717_ad$sd_2)
print(winter_sd_sens_717_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_717_ad$sd_2
## z = -0.23719, n = 34, p-value = 0.8125
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01195014 0.01072681
## sample estimates:
## Sen's slope
## -0.002045206
spring_standard_dev_all_717 <- standard_dev_717 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_717 <- spring_standard_dev_all_717 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_717 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.915288 |
| 1988 | 4.552524 |
| 1989 | 4.084735 |
| 1990 | 3.511877 |
| 1991 | 3.993001 |
| 1994 | 3.670914 |
| 1995 | 3.130044 |
| 1996 | 4.302921 |
| 1997 | 4.297618 |
| 1998 | 3.380682 |
| 1999 | 4.437436 |
| 2000 | 4.588449 |
| 2001 | 3.896187 |
| 2002 | 3.726636 |
| 2003 | 4.610864 |
| 2004 | 3.758258 |
| 2005 | 3.676604 |
| 2006 | 3.521178 |
| 2007 | 3.924077 |
| 2008 | 3.829295 |
| 2009 | 3.311054 |
| 2010 | 4.043445 |
| 2011 | 3.273519 |
| 2012 | 3.853739 |
| 2013 | 4.171176 |
| 2014 | 4.332028 |
| 2015 | 3.200452 |
| 2016 | 3.308506 |
| 2017 | 4.181797 |
| 2018 | 3.207366 |
| 2019 | 3.510591 |
| 2020 | 3.944077 |
| 2021 | 3.858749 |
| 2022 | 4.250542 |
ggplot(spring_standard_dev_all_717, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 717 average spring temperatures for water years 2005-2021
spring_sd_mk_717 <- mk.test(spring_standard_dev_all_717$sd_2)
print(spring_sd_mk_717)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_717$sd_2
## z = -0.85982, n = 34, p-value = 0.3899
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -59.0000000 4550.3333333 -0.1051693
spring_sd_sens_717 <- sens.slope(spring_standard_dev_all_717$sd_2)
print(spring_sd_sens_717)
##
## Sen's slope
##
## data: spring_standard_dev_all_717$sd_2
## z = -0.85982, n = 34, p-value = 0.3899
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.025113649 0.009518157
## sample estimates:
## Sen's slope
## -0.008243287
Fall
fall_standard_dev_all_717 <- standard_dev_717 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_717 <- fall_standard_dev_all_717 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_717 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.300996 |
| 1988 | 3.692732 |
| 1989 | 3.016863 |
| 1990 | 4.264319 |
| 1991 | 3.608502 |
| 1994 | 3.019284 |
| 1995 | 3.330218 |
| 1996 | 4.462253 |
| 1997 | 4.385067 |
| 1998 | 3.805551 |
| 1999 | 3.642157 |
| 2000 | 4.106109 |
| 2001 | 3.459445 |
| 2002 | 3.723556 |
| 2003 | 3.084738 |
| 2004 | 4.441646 |
| 2005 | 2.676165 |
| 2006 | 3.511499 |
| 2007 | 3.181780 |
| 2008 | 3.827247 |
| 2009 | 3.496022 |
| 2010 | 4.464998 |
| 2011 | 3.244665 |
| 2012 | 3.152114 |
| 2013 | 3.386952 |
| 2014 | 3.827335 |
| 2015 | 3.433937 |
| 2016 | 3.053215 |
| 2017 | 4.159668 |
| 2018 | 3.579810 |
| 2019 | 3.411787 |
| 2020 | 5.258055 |
| 2021 | 4.002369 |
| 2022 | 3.553143 |
ggplot(fall_standard_dev_all_717, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 717 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_717 <- mk.test(fall_standard_dev_all_717$sd_2)
print(fall_sd_mk_717)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_717$sd_2
## z = 0.41508, n = 34, p-value = 0.6781
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 29.0000000 4550.3333333 0.0516934
fall_sd_sens_717 <- sens.slope(fall_standard_dev_all_717$sd_2)
print(fall_sd_sens_717)
##
## Sen's slope
##
## data: fall_standard_dev_all_717$sd_2
## z = 0.41508, n = 34, p-value = 0.6781
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01594574 0.02084988
## sample estimates:
## Sen's slope
## 0.003892044
Spring
spring_standard_dev_all_717_ad <- standard_dev_717_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_717_ad <- spring_standard_dev_all_717_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_717_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.626498 |
| 1988 | 4.222830 |
| 1989 | 3.775377 |
| 1990 | 3.296075 |
| 1991 | 3.723715 |
| 1994 | 3.376716 |
| 1995 | 2.949087 |
| 1996 | 3.996385 |
| 1997 | 4.023573 |
| 1998 | 3.104451 |
| 1999 | 4.147730 |
| 2000 | 4.236400 |
| 2001 | 3.599100 |
| 2002 | 3.435452 |
| 2003 | 4.249693 |
| 2004 | 3.490958 |
| 2005 | 3.395982 |
| 2006 | 3.250296 |
| 2007 | 3.910671 |
| 2008 | 3.859653 |
| 2009 | 3.332855 |
| 2010 | 4.051319 |
| 2011 | 3.271206 |
| 2012 | 3.826297 |
| 2013 | 4.189788 |
| 2014 | 4.344861 |
| 2015 | 3.144249 |
| 2016 | 3.289767 |
| 2017 | 4.168952 |
| 2018 | 3.238819 |
| 2019 | 3.461501 |
| 2020 | 3.952389 |
| 2021 | 3.845782 |
| 2022 | 4.241782 |
ggplot(spring_standard_dev_all_717_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 717 average spring temperatures for water years 1986-2021
spring_sd_mk_717_ad <- mk.test(spring_standard_dev_all_717_ad$sd_2)
print(spring_sd_mk_717_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_717_ad$sd_2
## z = 0.44473, n = 34, p-value = 0.6565
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 3.100000e+01 4.550333e+03 5.525847e-02
spring_sd_sens_717_ad <- sens.slope(spring_standard_dev_all_717_ad$sd_2)
print(spring_sd_sens_717_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_717_ad$sd_2
## z = 0.44473, n = 34, p-value = 0.6565
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01216283 0.01937335
## sample estimates:
## Sen's slope
## 0.003391378
Fall
fall_standard_dev_all_717_ad <- standard_dev_717_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_717_ad <- fall_standard_dev_all_717_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_717_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.048081 |
| 1988 | 3.417611 |
| 1989 | 2.815361 |
| 1990 | 3.881493 |
| 1991 | 3.361460 |
| 1994 | 2.732692 |
| 1995 | 3.030575 |
| 1996 | 4.143793 |
| 1997 | 4.065907 |
| 1998 | 3.469235 |
| 1999 | 3.416906 |
| 2000 | 3.808552 |
| 2001 | 3.164955 |
| 2002 | 3.453855 |
| 2003 | 2.851065 |
| 2004 | 4.136895 |
| 2005 | 2.456142 |
| 2006 | 3.586155 |
| 2007 | 3.228872 |
| 2008 | 3.768488 |
| 2009 | 3.488571 |
| 2010 | 4.504971 |
| 2011 | 3.228025 |
| 2012 | 3.167645 |
| 2013 | 3.392653 |
| 2014 | 3.851091 |
| 2015 | 3.378543 |
| 2016 | 3.003291 |
| 2017 | 4.112073 |
| 2018 | 3.589000 |
| 2019 | 3.462996 |
| 2020 | 5.308473 |
| 2021 | 4.010569 |
| 2022 | 3.607163 |
ggplot(fall_standard_dev_all_717_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 717 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_717_ad <- mk.test(fall_standard_dev_all_717_ad$sd_2)
print(fall_sd_mk_717_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_717_ad$sd_2
## z = 1.6603, n = 34, p-value = 0.09685
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 113.000000 4550.333333 0.201426
fall_sd_sens_717_ad <- sens.slope(fall_standard_dev_all_717_ad$sd_2)
print(fall_sd_sens_717_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_717_ad$sd_2
## z = 1.6603, n = 34, p-value = 0.09685
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.001732358 0.033074963
## sample estimates:
## Sen's slope
## 0.0143572
Original 8/18/2004
snotel_825 <- SNOTEL_yampa_area %>%
filter(site_id == "825")
#str(snotel_825) # check the date, usually a character.
snotel_825$Date <- as.Date(snotel_825$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_825_clean <- snotel_825 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_825_clean <- snotel_825_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_825_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_825_clean <- snotel_825_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40) %>%
filter(temperature_mean < 30)
ggplot(snotel_825_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_825_cull_count <- snotel_825_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_825_cull_count
# filtering for too few observations in a year
snotel_825_cull_count_days <- snotel_825_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_825_cull_count_days
## # A tibble: 9 x 2
## # Groups: waterYear [9]
## waterYear n
## <dbl> <int>
## 1 1985 1
## 2 1987 348
## 3 1994 301
## 4 1995 347
## 5 1997 322
## 6 1998 343
## 7 1999 348
## 8 2002 327
## 9 2008 325
snotel_825_clean_culled <- snotel_825_clean %>%
filter(waterYear > "1987" & waterYear != "1994" & waterYear != "1995" & waterYear != "1997" & waterYear != "1998" & waterYear != "1999" & waterYear != "2002" & waterYear != "2008")# & waterYear != "2017" & waterYear != "2018")# & waterYear != "2002")# & waterYear != "2002" & waterYear != "2016" & waterYear != "2022")# & waterYear != "2017") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_825_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
ggplot(snotel_825_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_825_xts <- xts(snotel_825_clean_culled$temperature_mean, order.by = snotel_825_clean_culled$Date)
dygraph(temp_825_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_825_clean_culled <- snotel_825_clean_culled %>%
# filter(temperature_mean > -30)
#temp_825_xts <- xts(snotel_825_clean_culled$temperature_mean, order.by = snotel_825_clean_culled$Date)
#dygraph(temp_825_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
snotel_825_adjusted <- snotel_825_clean_culled %>%
mutate(temp_ad = if_else(Date < "2004-08-18", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_825 <- snotel_825_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_825 <- yearly_wy_aver_825 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(temperature_mean))
#average mean temperature by day for the period of record:
daily_wy_aver_825 <- daily_wy_aver_825 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_825$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_825 <-daily_wy_aver_825 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_825$date_temp <- signif(daily_wy_aver2_825$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_825, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_825 <- daily_wy_aver_825 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_825 <- standard_dev_825 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_825 <- standard_dev_all_825 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_825 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 4.370755 |
| 1989 | 4.502081 |
| 1990 | 4.094997 |
| 1991 | 4.494781 |
| 1992 | 4.418378 |
| 1993 | 3.862497 |
| 1996 | 4.285971 |
| 2000 | 4.095726 |
| 2001 | 3.960263 |
| 2003 | 3.856046 |
| 2004 | 4.206669 |
| 2005 | 3.688368 |
| 2006 | 4.106063 |
| 2007 | 4.075396 |
| 2009 | 4.002149 |
| 2010 | 4.014554 |
| 2011 | 3.893611 |
| 2012 | 3.781940 |
| 2013 | 4.141614 |
| 2014 | 3.859758 |
| 2015 | 4.069406 |
| 2016 | 3.519394 |
| 2017 | 4.268362 |
| 2018 | 3.604229 |
| 2019 | 3.588746 |
| 2020 | 4.031032 |
| 2021 | 4.007108 |
| 2022 | 4.061986 |
ggplot(standard_dev_all_825, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 825 average temperatures for water years 2005-2021
sd_mk_825 <- mk.test(standard_dev_all_825$sd_2)
print(sd_mk_825)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_825$sd_2
## z = -2.7857, n = 28, p-value = 0.005342
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -142.0000000 2562.0000000 -0.3756614
sd_sens_825 <- sens.slope(standard_dev_all_825$sd_2)
print(sd_sens_825)
##
## Sen's slope
##
## data: standard_dev_all_825$sd_2
## z = -2.7857, n = 28, p-value = 0.005342
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.033327212 -0.004654193
## sample estimates:
## Sen's slope
## -0.01801004
#using the clean culled df:
#average water year temperature
yearly_wy_aver_825_ad <- snotel_825_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_825_ad <- yearly_wy_aver_825_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_825_ad <- daily_wy_aver_825_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_825_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_825_ad <-daily_wy_aver_825_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_825_ad$date_temp_ad <- signif(daily_wy_aver2_825_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_825_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_825_ad <- daily_wy_aver_825_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_825_ad <- standard_dev_825_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_825_ad <- standard_dev_all_825_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_825_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 4.093580 |
| 1989 | 4.307244 |
| 1990 | 3.884354 |
| 1991 | 4.315506 |
| 1992 | 4.287504 |
| 1993 | 3.703147 |
| 1996 | 4.092826 |
| 2000 | 3.892889 |
| 2001 | 3.706820 |
| 2003 | 3.609904 |
| 2004 | 4.108226 |
| 2005 | 3.657357 |
| 2006 | 4.106002 |
| 2007 | 4.084842 |
| 2009 | 3.966318 |
| 2010 | 4.017505 |
| 2011 | 3.898041 |
| 2012 | 3.791951 |
| 2013 | 4.165666 |
| 2014 | 3.846573 |
| 2015 | 4.017305 |
| 2016 | 3.520567 |
| 2017 | 4.238999 |
| 2018 | 3.596848 |
| 2019 | 3.602665 |
| 2020 | 4.053922 |
| 2021 | 4.025947 |
| 2022 | 4.072057 |
ggplot(standard_dev_all_825_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 825 average temperatures for water years 1986-2021
sd_mk_825_ad <- mk.test(standard_dev_all_825_ad$sd_2)
print(sd_mk_825_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_825_ad$sd_2
## z = -1.3237, n = 28, p-value = 0.1856
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -68.0000000 2562.0000000 -0.1798942
sd_sens_825_ad <- sens.slope(standard_dev_all_825_ad$sd_2)
print(sd_sens_825_ad)
##
## Sen's slope
##
## data: standard_dev_all_825_ad$sd_2
## z = -1.3237, n = 28, p-value = 0.1856
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.020454781 0.005899708
## sample estimates:
## Sen's slope
## -0.006032826
Trapper Lake 827 Original 12/13/2004
summer_standard_dev_all_825 <- standard_dev_825 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_825 <- summer_standard_dev_all_825 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_825 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 2.498007 |
| 1989 | 3.350199 |
| 1990 | 3.167237 |
| 1991 | 2.507517 |
| 1992 | 3.212520 |
| 1993 | 3.356008 |
| 1996 | 2.065919 |
| 2000 | 2.640201 |
| 2001 | 3.178698 |
| 2003 | 3.214659 |
| 2004 | 2.905847 |
| 2005 | 3.044575 |
| 2006 | 2.754945 |
| 2007 | 2.620340 |
| 2009 | 2.632170 |
| 2010 | 2.343832 |
| 2011 | 2.493659 |
| 2012 | 2.443842 |
| 2013 | 2.277782 |
| 2014 | 2.558457 |
| 2015 | 2.799886 |
| 2016 | 2.395604 |
| 2017 | 2.140879 |
| 2018 | 2.407780 |
| 2019 | 2.743128 |
| 2020 | 2.943400 |
| 2021 | 3.277573 |
| 2022 | 2.294698 |
ggplot(summer_standard_dev_all_825, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 825 average summer temperatures for water years 2005-2021
summer_sd_mk_825 <- mk.test(summer_standard_dev_all_825$sd_2)
print(summer_sd_mk_825)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_825$sd_2
## z = -1.9559, n = 28, p-value = 0.05048
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -100.0000000 2562.0000000 -0.2645503
summer_sd_sens_825 <- sens.slope(summer_standard_dev_all_825$sd_2)
print(summer_sd_sens_825)
##
## Sen's slope
##
## data: summer_standard_dev_all_825$sd_2
## z = -1.9559, n = 28, p-value = 0.05048
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.0428372102 0.0004277878
## sample estimates:
## Sen's slope
## -0.02002212
Winter
winter_standard_dev_all_825 <- standard_dev_825 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_825 <- winter_standard_dev_all_825 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_825 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 4.791046 |
| 1989 | 5.226862 |
| 1990 | 4.564671 |
| 1991 | 5.301219 |
| 1992 | 4.773431 |
| 1993 | 4.172298 |
| 1996 | 4.835181 |
| 2000 | 4.512183 |
| 2001 | 4.158053 |
| 2003 | 4.003286 |
| 2004 | 4.643675 |
| 2005 | 4.193527 |
| 2006 | 4.753575 |
| 2007 | 4.786436 |
| 2009 | 4.728797 |
| 2010 | 4.410692 |
| 2011 | 4.663786 |
| 2012 | 4.378924 |
| 2013 | 4.942928 |
| 2014 | 4.072150 |
| 2015 | 4.739448 |
| 2016 | 4.142515 |
| 2017 | 4.956699 |
| 2018 | 4.079867 |
| 2019 | 3.971509 |
| 2020 | 3.847229 |
| 2021 | 4.196011 |
| 2022 | 4.681897 |
ggplot(winter_standard_dev_all_825, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 825 average winter temperatures for water years 2005-2021
winter_sd_mk_825 <- mk.test(winter_standard_dev_all_825$sd_2)
print(winter_sd_mk_825)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_825$sd_2
## z = -2.1139, n = 28, p-value = 0.03452
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -108.0000000 2562.0000000 -0.2857143
winter_sd_sens_825 <- sens.slope(winter_standard_dev_all_825$sd_2)
print(winter_sd_sens_825)
##
## Sen's slope
##
## data: winter_standard_dev_all_825$sd_2
## z = -2.1139, n = 28, p-value = 0.03452
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.041353103 -0.001861425
## sample estimates:
## Sen's slope
## -0.01890011
Summer
summer_standard_dev_all_825_ad <- standard_dev_825_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_825_ad <- summer_standard_dev_all_825_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_825_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 2.264095 |
| 1989 | 3.004068 |
| 1990 | 2.868951 |
| 1991 | 2.271338 |
| 1992 | 2.904141 |
| 1993 | 3.041441 |
| 1996 | 1.864347 |
| 2000 | 2.376586 |
| 2001 | 2.873112 |
| 2003 | 2.833907 |
| 2004 | 2.717289 |
| 2005 | 3.080534 |
| 2006 | 2.730974 |
| 2007 | 2.632687 |
| 2009 | 2.655070 |
| 2010 | 2.346837 |
| 2011 | 2.501445 |
| 2012 | 2.415534 |
| 2013 | 2.255060 |
| 2014 | 2.548523 |
| 2015 | 2.767070 |
| 2016 | 2.364032 |
| 2017 | 2.126034 |
| 2018 | 2.389925 |
| 2019 | 2.761848 |
| 2020 | 2.939172 |
| 2021 | 3.245537 |
| 2022 | 2.299311 |
ggplot(summer_standard_dev_all_825_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 825 average summer temperatures for water years 1986-2021
summer_sd_mk_825_ad <- mk.test(summer_standard_dev_all_825_ad$sd_2)
print(summer_sd_mk_825_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_825_ad$sd_2
## z = -0.73099, n = 28, p-value = 0.4648
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -38.0000000 2562.0000000 -0.1005291
summer_sd_sens_825_ad <- sens.slope(summer_standard_dev_all_825_ad$sd_2)
print(summer_sd_sens_825_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_825_ad$sd_2
## z = -0.73099, n = 28, p-value = 0.4648
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02820074 0.01067779
## sample estimates:
## Sen's slope
## -0.007702471
Winter
winter_standard_dev_all_825_ad <- standard_dev_825_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_825_ad <- winter_standard_dev_all_825_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_825_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 4.692676 |
| 1989 | 5.140780 |
| 1990 | 4.475759 |
| 1991 | 5.230649 |
| 1992 | 4.706138 |
| 1993 | 4.092225 |
| 1996 | 4.750864 |
| 2000 | 4.350990 |
| 2001 | 4.092541 |
| 2003 | 3.919800 |
| 2004 | 4.540504 |
| 2005 | 4.186796 |
| 2006 | 4.750588 |
| 2007 | 4.789937 |
| 2009 | 4.722557 |
| 2010 | 4.410803 |
| 2011 | 4.661772 |
| 2012 | 4.381019 |
| 2013 | 4.941163 |
| 2014 | 4.073485 |
| 2015 | 4.734769 |
| 2016 | 4.139333 |
| 2017 | 4.966836 |
| 2018 | 4.076670 |
| 2019 | 3.965657 |
| 2020 | 3.847914 |
| 2021 | 4.191345 |
| 2022 | 4.681709 |
ggplot(winter_standard_dev_all_825_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 825 average winter temperatures for water years 1986-2021
winter_sd_mk_825_ad <- mk.test(winter_standard_dev_all_825_ad$sd_2)
print(winter_sd_mk_825_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_825_ad$sd_2
## z = -1.5213, n = 28, p-value = 0.1282
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -78.0000000 2562.0000000 -0.2063492
winter_sd_sens_825_ad <- sens.slope(winter_standard_dev_all_825_ad$sd_2)
print(winter_sd_sens_825_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_825_ad$sd_2
## z = -1.5213, n = 28, p-value = 0.1282
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.037595019 0.003057104
## sample estimates:
## Sen's slope
## -0.01707785
spring_standard_dev_all_825 <- standard_dev_825 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_825 <- spring_standard_dev_all_825 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_825 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 4.761931 |
| 1989 | 4.550399 |
| 1990 | 3.662621 |
| 1991 | 4.554114 |
| 1992 | 3.736155 |
| 1993 | 3.130387 |
| 1996 | 4.234292 |
| 2000 | 4.451921 |
| 2001 | 4.117593 |
| 2003 | 4.580058 |
| 2004 | 4.323378 |
| 2005 | 3.812233 |
| 2006 | 3.625066 |
| 2007 | 4.223224 |
| 2009 | 3.481705 |
| 2010 | 4.137399 |
| 2011 | 3.271553 |
| 2012 | 4.184152 |
| 2013 | 4.343442 |
| 2014 | 4.396963 |
| 2015 | 3.432009 |
| 2016 | 3.420473 |
| 2017 | 4.482418 |
| 2018 | 3.489067 |
| 2019 | 3.667964 |
| 2020 | 4.205916 |
| 2021 | 4.085543 |
| 2022 | 4.354274 |
ggplot(spring_standard_dev_all_825, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 825 average spring temperatures for water years 2005-2021
spring_sd_mk_825 <- mk.test(spring_standard_dev_all_825$sd_2)
print(spring_sd_mk_825)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_825$sd_2
## z = -1.0866, n = 28, p-value = 0.2772
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -56.0000000 2562.0000000 -0.1481481
spring_sd_sens_825 <- sens.slope(spring_standard_dev_all_825$sd_2)
print(spring_sd_sens_825)
##
## Sen's slope
##
## data: spring_standard_dev_all_825$sd_2
## z = -1.0866, n = 28, p-value = 0.2772
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03223732 0.01283321
## sample estimates:
## Sen's slope
## -0.01102705
Fall
fall_standard_dev_all_825 <- standard_dev_825 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_825 <- fall_standard_dev_all_825 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_825 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 3.998686 |
| 1989 | 3.180077 |
| 1990 | 4.359677 |
| 1991 | 4.464831 |
| 1992 | 4.827888 |
| 1993 | 4.272250 |
| 1996 | 4.818924 |
| 2000 | 4.460234 |
| 2001 | 3.619401 |
| 2003 | 3.033418 |
| 2004 | 4.170721 |
| 2005 | 2.538015 |
| 2006 | 4.211455 |
| 2007 | 3.496186 |
| 2009 | 3.949427 |
| 2010 | 4.826059 |
| 2011 | 3.438867 |
| 2012 | 3.253248 |
| 2013 | 3.746012 |
| 2014 | 4.311159 |
| 2015 | 3.724828 |
| 2016 | 3.078421 |
| 2017 | 4.215611 |
| 2018 | 3.900683 |
| 2019 | 3.658276 |
| 2020 | 5.338671 |
| 2021 | 4.359969 |
| 2022 | 3.859736 |
ggplot(fall_standard_dev_all_825, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 825 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_825 <- mk.test(fall_standard_dev_all_825$sd_2)
print(fall_sd_mk_825)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_825$sd_2
## z = -0.49391, n = 28, p-value = 0.6214
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -26.00000000 2562.00000000 -0.06878307
fall_sd_sens_825 <- sens.slope(fall_standard_dev_all_825$sd_2)
print(fall_sd_sens_825)
##
## Sen's slope
##
## data: fall_standard_dev_all_825$sd_2
## z = -0.49391, n = 28, p-value = 0.6214
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03835404 0.02867110
## sample estimates:
## Sen's slope
## -0.007051284
Spring
spring_standard_dev_all_825_ad <- standard_dev_825_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_825_ad <- spring_standard_dev_all_825_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_825_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 4.422774 |
| 1989 | 4.221003 |
| 1990 | 3.443738 |
| 1991 | 4.255919 |
| 1992 | 3.483192 |
| 1993 | 2.864564 |
| 1996 | 3.941142 |
| 2000 | 4.130795 |
| 2001 | 3.826160 |
| 2003 | 4.224862 |
| 2004 | 4.040303 |
| 2005 | 3.815322 |
| 2006 | 3.619536 |
| 2007 | 4.217979 |
| 2009 | 3.494353 |
| 2010 | 4.137487 |
| 2011 | 3.267204 |
| 2012 | 4.158517 |
| 2013 | 4.371532 |
| 2014 | 4.410694 |
| 2015 | 3.393498 |
| 2016 | 3.409133 |
| 2017 | 4.468747 |
| 2018 | 3.516348 |
| 2019 | 3.633739 |
| 2020 | 4.217069 |
| 2021 | 4.083474 |
| 2022 | 4.356690 |
ggplot(spring_standard_dev_all_825_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 825 average spring temperatures for water years 1986-2021
spring_sd_mk_825_ad <- mk.test(spring_standard_dev_all_825_ad$sd_2)
print(spring_sd_mk_825_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_825_ad$sd_2
## z = 0.33586, n = 28, p-value = 0.737
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 1.800000e+01 2.562000e+03 4.761905e-02
spring_sd_sens_825_ad <- sens.slope(spring_standard_dev_all_825_ad$sd_2)
print(spring_sd_sens_825_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_825_ad$sd_2
## z = 0.33586, n = 28, p-value = 0.737
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01575352 0.02728554
## sample estimates:
## Sen's slope
## 0.00311489
Fall
fall_standard_dev_all_825_ad <- standard_dev_825_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_825_ad <- fall_standard_dev_all_825_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_825_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1988 | 3.715735 |
| 1989 | 3.010989 |
| 1990 | 3.953992 |
| 1991 | 4.154424 |
| 1992 | 4.538382 |
| 1993 | 4.028892 |
| 1996 | 4.486863 |
| 2000 | 4.173198 |
| 2001 | 3.332517 |
| 2003 | 2.808226 |
| 2004 | 4.239526 |
| 2005 | 2.560496 |
| 2006 | 4.163765 |
| 2007 | 3.522553 |
| 2009 | 3.933311 |
| 2010 | 4.866492 |
| 2011 | 3.434236 |
| 2012 | 3.273891 |
| 2013 | 3.766611 |
| 2014 | 4.325807 |
| 2015 | 3.697232 |
| 2016 | 3.037583 |
| 2017 | 4.185972 |
| 2018 | 3.918959 |
| 2019 | 3.691848 |
| 2020 | 5.377291 |
| 2021 | 4.369067 |
| 2022 | 3.895851 |
ggplot(fall_standard_dev_all_825_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 825 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_825_ad <- mk.test(fall_standard_dev_all_825_ad$sd_2)
print(fall_sd_mk_825_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_825_ad$sd_2
## z = 0.41489, n = 28, p-value = 0.6782
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 2.200000e+01 2.562000e+03 5.820106e-02
fall_sd_sens_825_ad <- sens.slope(fall_standard_dev_all_825_ad$sd_2)
print(fall_sd_sens_825_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_825_ad$sd_2
## z = 0.41489, n = 28, p-value = 0.6782
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02268728 0.04212681
## sample estimates:
## Sen's slope
## 0.00903793
Original 12/13/2004
snotel_827 <- SNOTEL_yampa_area %>%
filter(site_id == "827")
#str(snotel_827) # check the date, usually a character.
snotel_827$Date <- as.Date(snotel_827$date) #change date from character to date format, capitalize to work with Water year functon from NWIS.
#THIS WILL CHANGE FOR EACH STATION
snotel_827_clean <- snotel_827 %>% # filter for the timeframe
filter(Date >= "1979-10-01" & Date <= "2022-09-30") %>%
#filter(temperature_mean >= -30 & temperature_mean <= 20) %>% # removing outliers
addWaterYear() %>%
mutate(daymonth = format(as.Date(Date), "%d-%m")) %>%
na.omit()
#adding water day using difftime (SUPER COOL. example from [this](https://stackoverflow.com/questions/48123049/create-day-index-based-on-water-year))
snotel_827_clean <- snotel_827_clean %>%
group_by(waterYear)%>%
mutate(waterDay = (as.integer(difftime(Date, ymd(paste0(waterYear - 1 ,'-09-30')), units = "days"))))
# Check for outliers
ggplot(snotel_827_clean, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
snotel_827_clean <- snotel_827_clean %>%
mutate(temp_diff = abs(temperature_min - temperature_max)) %>%
filter(temperature_mean > -40) %>%
filter(temperature_mean < 30)
ggplot(snotel_827_clean, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
Per Steven’s advice: :If there are more than 15 missing days, then…remove that year”
# filtering for temperature anomalies
#snotel_827_cull_count <- snotel_827_clean %>%
# filter(temperature_min > -40) %>%
# count(waterYear)
#snotel_827_cull_count
# filtering for too few observations in a year
snotel_827_cull_count_days <- snotel_827_clean %>%
group_by(waterYear) %>%
count(waterYear) %>%
filter(n < 350)
snotel_827_cull_count_days
## # A tibble: 18 x 2
## # Groups: waterYear [18]
## waterYear n
## <dbl> <int>
## 1 1986 331
## 2 1994 179
## 3 1995 323
## 4 1996 53
## 5 1997 278
## 6 1999 341
## 7 2001 348
## 8 2002 310
## 9 2003 340
## 10 2004 342
## 11 2009 342
## 12 2010 346
## 13 2011 326
## 14 2013 236
## 15 2014 241
## 16 2016 321
## 17 2017 219
## 18 2019 332
snotel_827_clean_culled <- snotel_827_clean %>%
filter(waterYear != "1986" & waterYear != "1994" & waterYear != "1995" & waterYear != "1996" & waterYear != "1997" & waterYear != "1999" & waterYear != "2001" & waterYear != "2002" & waterYear != "2003" & waterYear != "2004" & waterYear != "2009" & waterYear != "2010" & waterYear != "2011" & waterYear != "2013" & waterYear != "2014" & waterYear != "2016" & waterYear != "2017" & waterYear != "2019") #%>%
#filter(temperature_mean > -49)
ggplot(snotel_827_clean_culled, aes(x = Date, y = temp_diff)) +
geom_point() + #lwd = 2) +
theme_few() +
#geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature varience (°C)') +
xlab('Date')
ggplot(snotel_827_clean_culled, aes(x = Date, y = temperature_mean)) +
geom_point() + #lwd = 2) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('Daily temperature (°C)') +
xlab('Date')
temp_827_xts <- xts(snotel_827_clean_culled$temperature_mean, order.by = snotel_827_clean_culled$Date)
dygraph(temp_827_xts) %>%
dyAxis("y", label = "Daily mean temperature (°C)")
#snotel_827_clean_culled <- snotel_827_clean_culled %>%
# filter(temperature_mean > -30)
#temp_827_xts <- xts(snotel_827_clean_culled$temperature_mean, order.by = snotel_827_clean_culled$Date)
#dygraph(temp_827_xts) %>%
# dyAxis("y", label = "Daily mean temperature (°C)")
Original 12/13/2004
snotel_827_adjusted <- snotel_827_clean_culled %>%
mutate(temp_ad = if_else(Date < "2004-12-13", ((5.3*10^(-7))*(temperature_mean^(4))+(3.72*10^(-5))*(temperature_mean^(3))-(2.16*10^(-3))*(temperature_mean^(2))-(7.32*10^(-2))*(temperature_mean)+1.37)+temperature_mean, temperature_mean))
Non-corrected
#using the clean culled df:
#average water year temperature
yearly_wy_aver_827 <- snotel_827_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp = mean(temperature_mean))
#Average temperature by day for all water years:
daily_wy_aver_827 <- yearly_wy_aver_827 %>%
group_by(daymonth) %>%
mutate(aver_day_temp = mean(temperature_mean))
#average mean temperature by day for the period of record:
daily_wy_aver_827 <- daily_wy_aver_827 %>%
group_by(daymonth) %>%
mutate(all_ave_temp = mean(daily_wy_aver_827$aver_day_temp))
# try to show all years as means.
daily_wy_aver2_827 <-daily_wy_aver_827 %>%
group_by(waterDay) %>%
mutate(date_temp = mean(temperature_mean))
daily_wy_aver2_827$date_temp <- signif(daily_wy_aver2_827$date_temp,3) #reduce the sig figs
ggplot(daily_wy_aver2_827, aes(x = waterDay, y = date_temp))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_827 <- daily_wy_aver_827 %>%
group_by(waterYear) %>%
mutate(residual = (all_ave_temp-aver_ann_temp)+temperature_mean-aver_day_temp) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_827 <- standard_dev_827 %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_827 <- standard_dev_all_827 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_827 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.827647 |
| 1988 | 4.061811 |
| 1989 | 4.637720 |
| 1990 | 3.836283 |
| 1991 | 3.893497 |
| 1992 | 3.761232 |
| 1993 | 3.877181 |
| 1998 | 3.823371 |
| 2000 | 3.948282 |
| 2005 | 3.538400 |
| 2006 | 4.127193 |
| 2007 | 4.051727 |
| 2008 | 4.006258 |
| 2012 | 3.553023 |
| 2015 | 3.983843 |
| 2018 | 3.654043 |
| 2020 | 4.131457 |
| 2021 | 3.776913 |
| 2022 | 4.102871 |
ggplot(standard_dev_all_827, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 827 average temperatures for water years 2005-2021
sd_mk_827 <- mk.test(standard_dev_all_827$sd_2)
print(sd_mk_827)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_827$sd_2
## z = 0.069971, n = 19, p-value = 0.9442
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 3.00000000 817.00000000 0.01754386
sd_sens_827 <- sens.slope(standard_dev_all_827$sd_2)
print(sd_sens_827)
##
## Sen's slope
##
## data: standard_dev_all_827$sd_2
## z = 0.069971, n = 19, p-value = 0.9442
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.02602614 0.01927385
## sample estimates:
## Sen's slope
## 0.001306779
#using the clean culled df:
#average water year temperature
yearly_wy_aver_827_ad <- snotel_827_adjusted %>%
group_by(waterYear) %>%
mutate(aver_ann_temp_ad = mean(temp_ad))
#Average temperature by day for all water years:
daily_wy_aver_827_ad <- yearly_wy_aver_827_ad %>%
group_by(daymonth) %>%
mutate(aver_day_temp_ad = mean(temp_ad))
#average mean temperature by day for the period of record:
daily_wy_aver_827_ad <- daily_wy_aver_827_ad %>%
group_by(daymonth) %>%
mutate(all_ave_temp_ad = mean(daily_wy_aver_827_ad$aver_day_temp_ad))
# try to show all years as means.
daily_wy_aver2_827_ad <-daily_wy_aver_827_ad %>%
group_by(waterDay) %>%
mutate(date_temp_ad = mean(temp_ad))
daily_wy_aver2_827_ad$date_temp_ad <- signif(daily_wy_aver2_827_ad$date_temp_ad,3) #reduce the sig figs
ggplot(daily_wy_aver2_827_ad, aes(x = waterDay, y = date_temp_ad))+
geom_line(size= 0.7) +
theme_few() +
ylab('Average Daily temperature (°C)') +
xlab('Day of water year')
standard_dev_827_ad <- daily_wy_aver_827_ad %>%
group_by(waterYear) %>%
#filter(waterYear >= 1987 & waterYear <= 2021) %>%
mutate(residual = (all_ave_temp_ad-aver_ann_temp_ad)+temp_ad-aver_day_temp_ad) %>%
mutate(deviation = abs(residual-lag(residual)))
standard_dev_all_827_ad <- standard_dev_827_ad %>%
group_by(waterYear) %>%
mutate(nmbr = n())
standard_dev_all_827_ad <- standard_dev_all_827_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
standard_dev_all_827_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.650798 |
| 1988 | 3.811999 |
| 1989 | 4.436876 |
| 1990 | 3.633448 |
| 1991 | 3.726137 |
| 1992 | 3.595942 |
| 1993 | 3.716321 |
| 1998 | 3.591304 |
| 2000 | 3.741694 |
| 2005 | 3.426567 |
| 2006 | 4.133144 |
| 2007 | 4.070690 |
| 2008 | 4.016840 |
| 2012 | 3.562569 |
| 2015 | 3.915549 |
| 2018 | 3.623543 |
| 2020 | 4.143138 |
| 2021 | 3.788869 |
| 2022 | 4.087724 |
ggplot(standard_dev_all_827_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 827 average temperatures for water years 1986-2021
sd_mk_827_ad <- mk.test(standard_dev_all_827_ad$sd_2)
print(sd_mk_827_ad)
##
## Mann-Kendall trend test
##
## data: standard_dev_all_827_ad$sd_2
## z = 0.69971, n = 19, p-value = 0.4841
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 21.000000 817.000000 0.122807
sd_sens_827_ad <- sens.slope(standard_dev_all_827_ad$sd_2)
print(sd_sens_827_ad)
##
## Sen's slope
##
## data: standard_dev_all_827_ad$sd_2
## z = 0.69971, n = 19, p-value = 0.4841
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01687878 0.03400068
## sample estimates:
## Sen's slope
## 0.01092049
Note: figure captions are incorrect.
summer_standard_dev_all_827 <- standard_dev_827 %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_827 <- summer_standard_dev_all_827 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_827 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.563520 |
| 1988 | 2.439337 |
| 1989 | 3.071556 |
| 1990 | 2.894219 |
| 1991 | 2.014236 |
| 1992 | 2.822673 |
| 1993 | 2.842504 |
| 1998 | 2.962266 |
| 2000 | 2.568110 |
| 2005 | 2.775151 |
| 2006 | 2.545877 |
| 2007 | 2.215610 |
| 2008 | 2.573560 |
| 2012 | 2.195553 |
| 2015 | 2.387615 |
| 2018 | 2.119442 |
| 2020 | 2.748857 |
| 2021 | 3.007755 |
| 2022 | 2.169263 |
ggplot(summer_standard_dev_all_827, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 827 average summer temperatures for water years 2005-2021
summer_sd_mk_827 <- mk.test(summer_standard_dev_all_827$sd_2)
print(summer_sd_mk_827)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_827$sd_2
## z = -1.3295, n = 19, p-value = 0.1837
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -39.0000000 817.0000000 -0.2280702
summer_sd_sens_827 <- sens.slope(summer_standard_dev_all_827$sd_2)
print(summer_sd_sens_827)
##
## Sen's slope
##
## data: summer_standard_dev_all_827$sd_2
## z = -1.3295, n = 19, p-value = 0.1837
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.05686104 0.01220211
## sample estimates:
## Sen's slope
## -0.02237268
Winter
winter_standard_dev_all_827 <- standard_dev_827 %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_827 <- winter_standard_dev_all_827 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_827 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.700936 |
| 1988 | 4.713817 |
| 1989 | 5.716836 |
| 1990 | 4.449391 |
| 1991 | 4.661980 |
| 1992 | 3.861395 |
| 1993 | 4.626797 |
| 1998 | 4.518215 |
| 2000 | 4.471254 |
| 2005 | 3.997341 |
| 2006 | 5.029591 |
| 2007 | 5.146738 |
| 2008 | 4.723129 |
| 2012 | 4.369610 |
| 2015 | 4.929553 |
| 2018 | 4.389624 |
| 2020 | 4.222537 |
| 2021 | 4.047845 |
| 2022 | 4.922237 |
ggplot(winter_standard_dev_all_827, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 827 average winter temperatures for water years 2005-2021
winter_sd_mk_827 <- mk.test(winter_standard_dev_all_827$sd_2)
print(winter_sd_mk_827)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_827$sd_2
## z = -0.83965, n = 19, p-value = 0.4011
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -25.0000000 817.0000000 -0.1461988
winter_sd_sens_827 <- sens.slope(winter_standard_dev_all_827$sd_2)
print(winter_sd_sens_827)
##
## Sen's slope
##
## data: winter_standard_dev_all_827$sd_2
## z = -0.83965, n = 19, p-value = 0.4011
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.04768133 0.02675729
## sample estimates:
## Sen's slope
## -0.02032882
Summer
summer_standard_dev_all_827_ad <- standard_dev_827_ad %>%
filter(waterDay >= 244 & waterDay <= 335) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
summer_standard_dev_all_827_ad <- summer_standard_dev_all_827_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
summer_standard_dev_all_827_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.306756 |
| 1988 | 2.210476 |
| 1989 | 2.739765 |
| 1990 | 2.616480 |
| 1991 | 1.821334 |
| 1992 | 2.541072 |
| 1993 | 2.553339 |
| 1998 | 2.644095 |
| 2000 | 2.331907 |
| 2005 | 2.816581 |
| 2006 | 2.522406 |
| 2007 | 2.242314 |
| 2008 | 2.589671 |
| 2012 | 2.173174 |
| 2015 | 2.362053 |
| 2018 | 2.102200 |
| 2020 | 2.734442 |
| 2021 | 2.967900 |
| 2022 | 2.152661 |
ggplot(summer_standard_dev_all_827_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 827 average summer temperatures for water years 1986-2021
summer_sd_mk_827_ad <- mk.test(summer_standard_dev_all_827_ad$sd_2)
print(summer_sd_mk_827_ad)
##
## Mann-Kendall trend test
##
## data: summer_standard_dev_all_827_ad$sd_2
## z = -0.069971, n = 19, p-value = 0.9442
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -3.00000000 817.00000000 -0.01754386
summer_sd_sens_827_ad <- sens.slope(summer_standard_dev_all_827_ad$sd_2)
print(summer_sd_sens_827_ad)
##
## Sen's slope
##
## data: summer_standard_dev_all_827_ad$sd_2
## z = -0.069971, n = 19, p-value = 0.9442
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03338982 0.03447235
## sample estimates:
## Sen's slope
## -0.002978772
Winter
winter_standard_dev_all_827_ad <- standard_dev_827_ad %>%
filter(waterDay >= 32 & waterDay <= 182) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
winter_standard_dev_all_827_ad <- winter_standard_dev_all_827_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
winter_standard_dev_all_827_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 4.575071 |
| 1988 | 4.587314 |
| 1989 | 5.597093 |
| 1990 | 4.327783 |
| 1991 | 4.577631 |
| 1992 | 3.779147 |
| 1993 | 4.531983 |
| 1998 | 4.396865 |
| 2000 | 4.304574 |
| 2005 | 3.869786 |
| 2006 | 5.034847 |
| 2007 | 5.154815 |
| 2008 | 4.715058 |
| 2012 | 4.376219 |
| 2015 | 4.923204 |
| 2018 | 4.374732 |
| 2020 | 4.214034 |
| 2021 | 4.034780 |
| 2022 | 4.908400 |
ggplot(winter_standard_dev_all_827_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 827 average winter temperatures for water years 1986-2021
winter_sd_mk_827_ad <- mk.test(winter_standard_dev_all_827_ad$sd_2)
print(winter_sd_mk_827_ad)
##
## Mann-Kendall trend test
##
## data: winter_standard_dev_all_827_ad$sd_2
## z = -0.62974, n = 19, p-value = 0.5289
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -19.0000000 817.0000000 -0.1111111
winter_sd_sens_827_ad <- sens.slope(winter_standard_dev_all_827_ad$sd_2)
print(winter_sd_sens_827_ad)
##
## Sen's slope
##
## data: winter_standard_dev_all_827_ad$sd_2
## z = -0.62974, n = 19, p-value = 0.5289
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.04520030 0.03136811
## sample estimates:
## Sen's slope
## -0.01131746
spring_standard_dev_all_827 <- standard_dev_827 %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_827 <- spring_standard_dev_all_827 %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_827 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.551482 |
| 1988 | 4.270747 |
| 1989 | 4.696154 |
| 1990 | 3.387587 |
| 1991 | 4.185920 |
| 1992 | 3.659416 |
| 1993 | 3.233119 |
| 1998 | 2.992308 |
| 2000 | 4.562073 |
| 2005 | 3.779103 |
| 2006 | 3.446439 |
| 2007 | 3.556846 |
| 2008 | 3.843335 |
| 2012 | 3.700609 |
| 2015 | 3.097907 |
| 2018 | 3.403852 |
| 2020 | 3.784520 |
| 2021 | 3.673243 |
| 2022 | 4.377378 |
ggplot(spring_standard_dev_all_827, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 827 average spring temperatures for water years 2005-2021
spring_sd_mk_827 <- mk.test(spring_standard_dev_all_827$sd_2)
print(spring_sd_mk_827)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_827$sd_2
## z = -0.13994, n = 19, p-value = 0.8887
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## -5.00000000 817.00000000 -0.02923977
spring_sd_sens_827 <- sens.slope(spring_standard_dev_all_827$sd_2)
print(spring_sd_sens_827)
##
## Sen's slope
##
## data: spring_standard_dev_all_827$sd_2
## z = -0.13994, n = 19, p-value = 0.8887
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.06192107 0.03240055
## sample estimates:
## Sen's slope
## -0.009842018
Fall
fall_standard_dev_all_827 <- standard_dev_827 %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_827 <- fall_standard_dev_all_827 %>%
#group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_827 %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.834833 |
| 1988 | 3.308293 |
| 1989 | 3.245410 |
| 1990 | 3.892369 |
| 1991 | 3.670883 |
| 1992 | 3.997704 |
| 1993 | 3.737742 |
| 1998 | 3.713881 |
| 2000 | 3.530093 |
| 2005 | 2.539018 |
| 2006 | 4.071424 |
| 2007 | 3.422620 |
| 2008 | 3.605344 |
| 2012 | 2.791163 |
| 2015 | 2.941302 |
| 2018 | 3.457498 |
| 2020 | 5.441607 |
| 2021 | 3.983392 |
| 2022 | 3.360771 |
ggplot(fall_standard_dev_all_827, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Non-corrected standard deviation of SNOTEL 827 average fall temperatures for water years 2005-2021. Note that the season is split by the water year.
fall_sd_mk_827 <- mk.test(fall_standard_dev_all_827$sd_2)
print(fall_sd_mk_827)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_827$sd_2
## z = 0.34986, n = 19, p-value = 0.7264
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 11.00000000 817.00000000 0.06432749
fall_sd_sens_827 <- sens.slope(fall_standard_dev_all_827$sd_2)
print(fall_sd_sens_827)
##
## Sen's slope
##
## data: fall_standard_dev_all_827$sd_2
## z = 0.34986, n = 19, p-value = 0.7264
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03546606 0.08045693
## sample estimates:
## Sen's slope
## 0.01065753
Spring
spring_standard_dev_all_827_ad <- standard_dev_827_ad %>%
filter(waterDay >= 183 & waterDay <= 243) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
spring_standard_dev_all_827_ad <- spring_standard_dev_all_827_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
spring_standard_dev_all_827_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 3.283306 |
| 1988 | 3.949633 |
| 1989 | 4.352872 |
| 1990 | 3.176078 |
| 1991 | 3.875136 |
| 1992 | 3.390968 |
| 1993 | 2.961022 |
| 1998 | 2.706316 |
| 2000 | 4.195405 |
| 2005 | 3.784639 |
| 2006 | 3.437721 |
| 2007 | 3.540985 |
| 2008 | 3.865635 |
| 2012 | 3.671452 |
| 2015 | 3.047425 |
| 2018 | 3.438750 |
| 2020 | 3.799299 |
| 2021 | 3.655888 |
| 2022 | 4.370353 |
ggplot(spring_standard_dev_all_827_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 827 average spring temperatures for water years 1986-2021
spring_sd_mk_827_ad <- mk.test(spring_standard_dev_all_827_ad$sd_2)
print(spring_sd_mk_827_ad)
##
## Mann-Kendall trend test
##
## data: spring_standard_dev_all_827_ad$sd_2
## z = 0.41983, n = 19, p-value = 0.6746
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 13.00000000 817.00000000 0.07602339
spring_sd_sens_827_ad <- sens.slope(spring_standard_dev_all_827_ad$sd_2)
print(spring_sd_sens_827_ad)
##
## Sen's slope
##
## data: spring_standard_dev_all_827_ad$sd_2
## z = 0.41983, n = 19, p-value = 0.6746
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.03954096 0.05570364
## sample estimates:
## Sen's slope
## 0.0108003
Fall
fall_standard_dev_all_827_ad <- standard_dev_827_ad %>%
filter(waterDay >= 336 | waterDay <= 31) %>%
group_by(waterYear) %>%
mutate(nmbr = n())
fall_standard_dev_all_827_ad <- fall_standard_dev_all_827_ad %>%
group_by(waterYear) %>%
mutate(resid_mean = mean(residual)) %>%
mutate(sd_1 = residual-resid_mean) %>%
mutate(sd_2 = (((sum((sd_1)^2))/((nmbr-1))))^(0.5)) %>%
distinct(sd_2, .keep_all = TRUE) %>%
select(waterYear, sd_2)
fall_standard_dev_all_827_ad %>%
kable(.,'html') %>%
kable_styling() %>%
scroll_box(width='250px',height='500px')
| waterYear | sd_2 |
|---|---|
| 1987 | 2.659042 |
| 1988 | 3.079897 |
| 1989 | 3.030043 |
| 1990 | 3.562460 |
| 1991 | 3.430062 |
| 1992 | 3.725277 |
| 1993 | 3.504965 |
| 1998 | 3.379884 |
| 2000 | 3.253929 |
| 2005 | 2.246862 |
| 2006 | 4.000100 |
| 2007 | 3.467832 |
| 2008 | 3.555835 |
| 2012 | 2.796832 |
| 2015 | 2.880085 |
| 2018 | 3.483005 |
| 2020 | 5.498296 |
| 2021 | 3.988948 |
| 2022 | 3.408219 |
ggplot(fall_standard_dev_all_827_ad, aes(x = waterYear, y = sd_2))+
geom_line(size= 0.7) +
theme_few() +
geom_smooth(method = "lm", se=FALSE) +
ylab('SD') +
xlab('Water year')
Morrisey-corrected standard deviation of SNOTEL 827 average fall temperatures for water years 1986-2021. Note that the fall season is split by the water year.
fall_sd_mk_827_ad <- mk.test(fall_standard_dev_all_827_ad$sd_2)
print(fall_sd_mk_827_ad)
##
## Mann-Kendall trend test
##
## data: fall_standard_dev_all_827_ad$sd_2
## z = 1.1895, n = 19, p-value = 0.2342
## alternative hypothesis: true S is not equal to 0
## sample estimates:
## S varS tau
## 35.0000000 817.0000000 0.2046784
fall_sd_sens_827_ad <- sens.slope(fall_standard_dev_all_827_ad$sd_2)
print(fall_sd_sens_827_ad)
##
## Sen's slope
##
## data: fall_standard_dev_all_827_ad$sd_2
## z = 1.1895, n = 19, p-value = 0.2342
## alternative hypothesis: true z is not equal to 0
## 95 percent confidence interval:
## -0.01537019 0.08501357
## sample estimates:
## Sen's slope
## 0.03272511